Sample workflows

A hardened test workflow

A test job with the usual protections. It comes out clean.

permissions: {} at the top and contents: read for the one job; persist-credentials: false on the checkout; both actions pinned to commits with their versions in comments; and the pull request's branch name passed to the script through env:.

# A test workflow with the usual protections: read-only token, no stored# credentials, actions pinned to commits, and event data passed through env.name: Test on:  pull_request: permissions: {} jobs:  test:    runs-on: ubuntu-latest    permissions:      contents: read    steps:      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0        with:          persist-credentials: false      - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0        with:          node-version: 22      - run: npm ci      - run: npm test      - name: Report        run: echo "Tested $HEAD_REF"        env:          HEAD_REF: ${{ github.head_ref }}