diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae93fdb..d2defc0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,32 +11,10 @@ concurrency: cancel-in-progress: true jobs: - verify: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - with: - fetch-depth: 0 - - uses: actions/setup-node@v7 - with: - node-version: 22 - cache: npm - - run: npm ci - - run: npm run format:check - - run: npm run lint - - run: npm run type:check - - run: npm run test:run - - name: Mutation targets - if: github.event_name == 'pull_request' - id: targets - env: - BASE: origin/${{ github.base_ref }} - run: echo "files=$(scripts/mutation-targets.sh "$BASE")" >> "$GITHUB_OUTPUT" - - name: Mutation test the changed logic - if: github.event_name == 'pull_request' && steps.targets.outputs.files != '' - timeout-minutes: 40 - env: - FILES: ${{ steps.targets.outputs.files }} - run: | - npm i --no-save @stryker-mutator/core@10.1.1 @stryker-mutator/vitest-runner@10.1.1 - npx stryker run --mutate "$FILES" + ci: + permissions: + contents: read + pull-requests: write + uses: Endika/.github/.github/workflows/web-ci.yml@v1 + with: + mutation-timeout: 40 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b381e28..bcf2032 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -6,28 +6,15 @@ on: pull_request: branches: [main] schedule: - - cron: "0 6 * * 1" + - cron: 0 6 * * 1 permissions: contents: read jobs: - analyze: - name: Analyze JavaScript/TypeScript - runs-on: ubuntu-latest - timeout-minutes: 20 + codeql: permissions: security-events: write actions: read contents: read - steps: - - uses: actions/checkout@v7 - - - uses: github/codeql-action/init@v4 - with: - languages: javascript-typescript - queries: security-and-quality - - - uses: github/codeql-action/analyze@v4 - with: - category: "/language:javascript-typescript" + uses: Endika/.github/.github/workflows/codeql.yml@v1 diff --git a/.github/workflows/delete-closed-pr-branch.yml b/.github/workflows/delete-closed-pr-branch.yml index a7893da..e323a21 100644 --- a/.github/workflows/delete-closed-pr-branch.yml +++ b/.github/workflows/delete-closed-pr-branch.yml @@ -5,15 +5,10 @@ on: types: [closed] permissions: - contents: write + contents: read jobs: delete: - if: github.event.pull_request.head.repo.full_name == github.repository - runs-on: ubuntu-latest - steps: - - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ github.repository }} - BRANCH: ${{ github.event.pull_request.head.ref }} - run: gh api -X DELETE "repos/$REPO/git/refs/heads/$BRANCH" 2>/dev/null || true + permissions: + contents: write + uses: Endika/.github/.github/workflows/delete-closed-pr-branch.yml@v1 diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index af6f5aa..81565ae 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -1,26 +1,16 @@ name: Dependabot auto-merge +# pull_request_target hands the run the Actions secrets (the PAT); the called +# workflow only acts on same-repo Dependabot pull requests and never checks out their code. on: pull_request_target permissions: - contents: write - pull-requests: write + contents: read jobs: auto-merge: - # This job holds the PAT: only same-repo pull requests opened by Dependabot itself. - if: >- - github.event.pull_request.user.login == 'dependabot[bot]' - && github.event.pull_request.head.repo.full_name == github.repository - runs-on: ubuntu-latest - steps: - - id: meta - uses: dependabot/fetch-metadata@v3 - # The PAT, not GITHUB_TOKEN: a merge authored by GITHUB_TOKEN is a push that - # triggers no workflow at all, so neither release-please nor the deploy would - # ever run for an auto-merged bump. - - if: steps.meta.outputs.update-type == 'version-update:semver-minor' || steps.meta.outputs.update-type == 'version-update:semver-patch' - env: - GH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }} - PR_URL: ${{ github.event.pull_request.html_url }} - run: gh pr merge --rebase --auto "$PR_URL" + permissions: + contents: write + pull-requests: write + uses: Endika/.github/.github/workflows/dependabot-auto-merge.yml@v1 + secrets: inherit diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 40ccd7d..d35e986 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,46 +7,16 @@ on: permissions: contents: read - pages: write - id-token: write concurrency: group: pages cancel-in-progress: false jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: actions/setup-node@v7 - with: - node-version: 22 - cache: npm - - run: npm ci - - run: npm run build - env: - VITE_SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }} - VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }} - VITE_GOOGLE_MAPS_KEY: ${{ secrets.VITE_GOOGLE_MAPS_KEY }} - - uses: actions/configure-pages@v6 - - uses: actions/upload-pages-artifact@v5 - with: - path: dist - deploy: - needs: build - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deploy.outputs.page_url || steps.deploy_retry.outputs.page_url }} - steps: - - id: deploy - continue-on-error: true - uses: actions/deploy-pages@v5 - # Pages sometimes cannot see the artifact just uploaded; a rerun would upload a second one. - - if: steps.deploy.outcome == 'failure' - run: sleep 60 - - id: deploy_retry - if: steps.deploy.outcome == 'failure' - uses: actions/deploy-pages@v5 + permissions: + contents: read + pages: write + id-token: write + uses: Endika/.github/.github/workflows/web-deploy.yml@v1 + secrets: inherit diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index da31115..e8bf184 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -6,8 +6,7 @@ on: workflow_dispatch: permissions: - contents: write - pull-requests: write + contents: read concurrency: group: release-${{ github.ref }} @@ -15,22 +14,8 @@ concurrency: jobs: release-please: - runs-on: ubuntu-latest - steps: - - id: release - uses: googleapis/release-please-action@v5 - with: - token: ${{ secrets.RELEASE_PLEASE_TOKEN }} - config-file: release-please-config.json - manifest-file: .release-please-manifest.json - - # Enable native auto-merge and stop; GitHub rebase-merges once the required - # checks pass, and that PAT-authored merge is a push to main that both - # re-triggers this workflow to cut the tag/release and triggers the deploy - # (on: push), so no explicit deploy dispatch is needed here. - - if: ${{ steps.release.outputs.pr }} - env: - GH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }} - REPO: ${{ github.repository }} - PR_JSON: ${{ steps.release.outputs.pr }} - run: gh pr merge --rebase --auto -R "$REPO" "$(echo "$PR_JSON" | jq -r .number)" + permissions: + contents: write + pull-requests: write + uses: Endika/.github/.github/workflows/release-please.yml@v1 + secrets: inherit diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml deleted file mode 100644 index 861de7e..0000000 --- a/.github/workflows/security.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Security - -on: - pull_request: - -permissions: - contents: read - -jobs: - dependency-review: - name: Dependency review - runs-on: ubuntu-latest - timeout-minutes: 10 - permissions: - contents: read - pull-requests: write - steps: - - uses: actions/checkout@v7 - - uses: actions/dependency-review-action@v5 - with: - fail-on-severity: high - comment-summary-in-pr: on-failure