Skip to content

chore: harden GA workflow files - #412

Closed
Florence-Njeri wants to merge 3 commits into
asyncapi:masterfrom
Florence-Njeri:harden-GA
Closed

chore: harden GA workflow files#412
Florence-Njeri wants to merge 3 commits into
asyncapi:masterfrom
Florence-Njeri:harden-GA

Conversation

@Florence-Njeri

@Florence-Njeri Florence-Njeri commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Pinned all action references to commit SHAs (moving from tag-pinned to SHA-pinned) to prevent tag-move supply chain attacks across the org
  • Added workflow_dispatch: trigger to all workflows to allow manual re-runs without waiting for a push event
  • Added permissions: {} at workflow level with minimal job-level scopes to fix excessive-permissions (without this block, workflows inherit write-all permissions from the parent token)
  • Set persist-credentials: false on read-only checkouts; kept true only where git push is required
  • Replaced embedded-token push URLs (https://${{ env.GITHUB_TOKEN }}.github.) with git push origin HEAD to prevent token exposure in logs and process listings (template-injection)
  • Moved github.sha and github.run_id expansions into env: vars to keep shell steps injection-safe
  • Scoped git config to the repository instead of --global in update-docs-in-website.yml
  • Split the manual_netlify_preview.yml workflow into a two-stage build + deploy pattern (manual_netlify_preview.yml) following GitHub's hardened workflow best practices to eliminate pwn_request risks — the deploy stage runs under a protected environment (docs-preview) that requires maintainer approval before secrets are exposed

Workflows that were edited:

  • local-generate-files.yml — autogenerate API asset files on release
  • manual_netlify_preview.yml — secure two-stage Netlify docs preview deploy (triggered via workflow_run)
  • pr-review-checklist.yml — post PR review checklist with least-privilege permissions
  • pr-testing-with-test-project.yml — integration and acceptance tests with scoped job permissions
  • release-with-changesets.yml — changeset-based release workflow with deny-all workflow token
  • update-docs-in-website.yml — sync generator docs to asyncapi/website via hardened checkout
  • update-maintainers.yml — update MAINTAINERS.yaml with deny-all built-in token; uses PAT for cross-repo writes
  • verify-docs-up-to-date.yml — verify generated docs have no drift on PRs

Related issue(s)
TBC

startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'allcontributors[bot]' &&
Comment on lines +3 to +6
on:
workflow_run:
workflows: ["Docs Preview Build (Netlify)"]
types: [completed]

permissions:
contents: read
pull-requests: write # only for the comment step
Comment on lines +3 to +6
on:
pull_request_target:
types:
- opened
node-version: ${{ vars.NODE_VERSION }}

- name: Use Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.2.0 https://github.com/actions/setup-node/commit/48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
# Revokes default permissions since all jobs only need read access.
permissions: {}
jobs:
changes:
persist-credentials: false # read-only; only used to access .github/pr-review-checklist.md

- name: Post initial PR checklist
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 #v4.0.0 https://github.com/peter-evans/create-or-update-comment/releases/tag/v4.0.0
Comment on lines +1 to +32
name: PR Review Checklist

on:
pull_request_target:
types:
- opened

permissions: {}

jobs:
pr-review-list:
name: Post PR Review Checklist
# it runs only if PR actor is not a bot, at least not a bot that we know
if: |
(github.event.pull_request.user.login != 'asyncapi-bot' &&
github.event.pull_request.user.login != 'dependabot[bot]' &&
github.event.pull_request.user.login != 'dependabot-preview[bot]')
runs-on: ubuntu-latest
permissions:
pull-requests: write # permission to create-or-update-comment posts to the PR thread
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # read-only; only used to access .github/pr-review-checklist.md

- name: Post initial PR checklist
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 #v4.0.0 https://github.com/peter-evans/create-or-update-comment/releases/tag/v4.0.0
with:
token: ${{ secrets.GH_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body-path: '.github/pr-review-checklist.md' No newline at end of file
actions: read # to download artifacts from the triggering run

jobs:
deploy:
- name: Assets generation
run: npm run generate:assets --if-present
- name: Create Pull Request with updated asset files including package.json
uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # use 4.2.4 https://github.com/peter-evans/create-pull-request/releases/tag/v4.2.4
@Florence-Njeri Florence-Njeri changed the title Harden ga chore: harden GA workflow files Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants