Skip to content

Commit

Permalink
Refactor GitHub Actions (#120)
Browse files Browse the repository at this point in the history
* Add commit prefix to Dependabot config

* Add publish workflow, update CI workflow
  • Loading branch information
jgarber623 authored Oct 14, 2023
1 parent b4365c6 commit dea8917
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ updates:
interval: "weekly"
assignees:
- "jgarber623"
commit-message:
prefix: "ci"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
assignees:
- "jgarber623"
commit-message:
prefix: "chore"
44 changes: 9 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
name: CI

on: [push, pull_request]
on:
pull_request:
workflow_call:
workflow_dispatch:

jobs:
analyze:
name: Analyze
permissions:
contents: read
security-events: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v2
with:
languages: javascript
- uses: github/codeql-action/analyze@v2
lint:
name: Lint
runs-on: ubuntu-latest
Expand All @@ -26,35 +17,18 @@ jobs:
cache: npm
- run: npm ci
- run: npm run lint
build:
name: Build
needs: [analyze, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
- run: npm ci
- run: npm run build
- name: Check for changed files
run: |
git status
git diff --quiet
test:
name: Test
needs: build
runs-on: macos-latest
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
browser: ["headlessChrome", "headlessFirefox", "MicrosoftEdge", "safari"]
fail-fast: false
version: [18, 20]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
node-version: ${{ matrix.version }}
cache: npm
- run: npm ci
- run: npm test -- --browser=${{ matrix.browser }}
- run: npm test
52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish

on:
release:
types: [published]

jobs:
ci:
name: CI
uses: ./.github/workflows/ci.yml
publish-to-npm:
name: Publish to npm
permissions:
contents: read
id-token: write
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm run build
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-to-github-packages:
name: Publish to GitHub Packages
permissions:
contents: read
packages: write
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Change package scope
run: |
sed -i -E "s/@.+(\/cashcash)/@${{ github.repository_owner }}\1/" package.json
cat package.json
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: npm
registry-url: https://npm.pkg.github.com
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit dea8917

Please sign in to comment.