Secure GitHub Actions CI pipeline with caching and least privilege

by fidji ChatGPT English ~678 tokens
Public excerpt Locked
Job graph (lint → test matrix → build → audit), cache keyed on the lockfile hash, concurrency group that cancels outdated runs, permissions: contents: read at the top, third-party actions pinned to a full SHA, untrusted event fields passed through env, never pull_request_target with checkout…

About this prompt

Generates a commented GitHub Actions workflow for your stack: lint, tests with service containers, build, dependency audit, with lockfile-keyed caching, concurrency cancellation and path filters. Security is built in: read-only token by default, actions pinned to commit SHAs, no secrets on fork PRs, OIDC for cloud access, no script injection from event data.

Example output

Provided by the author
```yaml name: ci on: pull_request: push: branches: [main] permissions: contents: read # read-only token by default concurrency: group: ci-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: test: runs-on: ubuntu-latest timeout-minutes: 15 strategy: matrix: { node: [20, 22] } services: postgres: image: postgres:16 env: { POSTGRES_PASSWORD: test } ports: ['5432:5432'] options: --health-cmd pg_isready --health-interval 5s steps: - uses: actions/checkout@<FULL_COMMIT_SHA> # v4 - uses: pnpm/action-setup@<FULL_COMMIT_SHA> # v4 - uses: actions/setup-node@<FULL_COMMIT_SHA> # v4 with: { node-version: '${{ matrix.node }}', cache: pnpm } - run: pnpm install --frozen-lockfile - run: pnpm test env: { DATABASE_URL: 'postgres://postgres:test@localhost:5432/postgres' } ``` Resolve SHAs: open the action's release page, copy the commit of the tag, keep the tag in the comment…

Details

Model
ChatGPT
Prompt language
English
Who it's for
Developers and DevOps engineers setting up or cleaning up CI on GitHub for an app or library
Length
~678 tokens (estimate)
Delivered as
Prompt text, shown online after purchase

Reviews

Buyers only

No reviews yet. Only buyers of this prompt can leave one.

Report this prompt