agentleFS
leroyguillaumeleroyguillaume/skills/github-actions-conventions/SKILL.md

github-actions-conventions

Skill7 starsChanged 2 days agoMITView on GitHub

GitHub Actions mechanics: workflows, pinned actions, SARIF, release notes, Releases, Pages. TRIGGER when: editing anything under `.github/workflows/` or `.github/actions/`, `.github/release.yaml`, or an `action.yaml`/`.yml`; setting up CI on GitHub; user asks about Actions, runners, SARIF, script injection or `pull_request_target`, GitHub Releases, Pages, the OpenSSF Scorecard workflow or the coverage report. SKIP when: the repo is not on GitHub (`gitlab-ci-conventions`). Load `ci-conventions` alongside.

  • Pipes a download into a shell
  • Reads credentials
  • Commits and pushes

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 4 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Write the trigger key as bare on:, never quoted "on":.

    line 27
  2. Very specific:

    Keep step names static. Never interpolate ${{ }} into a name:.

    line 37
  3. Very specific:

    Never use a bare branch or tag ref (@v4, @main, @stable).

    line 50
  4. Very specific:

    Only the jobs of quality and, when it exists, security (never filtered) are required, in the default branch's ruleset …

    line 116
  5. Distinctive:

    No mise or npm cache: both are downloads.

    line 247
  6. Very specific:

    Always present when a release workflow exists.

    line 251
  7. Distinctive:

    Every workflow has a top-level block:

    line 404
  8. Very specific:

    Never start a workflow file with ---, and never quote "on".

    line 450
  9. Distinctive:

    Never use a bare branch/tag action ref.

    line 451
  10. Very specific:

    Never put ${{ }} in a run: script, and never trigger on pull_request_target.

    line 452
  11. Very specific:

    Never make a paths-filtered workflow, or coverage, a required check.

    line 454
  12. Very specific:

    Never share one unscoped type=gha cache across architectures.

    line 455
  13. Very specific:

    Never use ${{ github.workflow }} in the concurrency group of a reusable workflow.

    line 456
  14. Very specific:

    Never let two SARIF uploads share a category.

    line 458
  15. Distinctive:

    Never deploy Pages from a tag run.

    line 459

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

GitHub Actions conventions

How the pipelines from ci-conventions are written on GitHub. One workflow file per canonical pipeline the repo needs: .github/workflows/quality.yaml, coverage.yaml, build.yaml, security.yaml, chart.yaml, release.yaml, docs.yaml. ci-conventions says which ones a repo has; a repo with no lockfile and no published image has no security.yaml. A public repository also has scorecard.yaml (below).

YAML style

Write the trigger key as bare on:, never quoted "on":. Everything else is yaml-conventions.

Step naming

  • Every step has a name:. It is mandatory for uses: steps and expected on run: steps. A nameless action step reads as a bare SHA in the UI.
  • Step names start with a lowercase letter: name: set up the Rust toolchain. Proper nouns keep their capitals (Rust, GHCR, GitHub).
  • Keep step names static. Never interpolate ${{ }} into a name:.

Pin actions by SHA

  • Pin every uses: to a full commit SHA, with a trailing comment naming the latest release tag it corresponds to:
    - uses: actions/checkout@<40-char-sha>  # vX.Y.Z
    Resolve it with git ls-remote --tags https://github.com/<owner>/<repo> '<tag>^{}'.
  • Renovate's github-actions manager bumps the SHAs and their tag comments together (dependency-update-conventions).
  • Never use a bare branch or tag ref (@v4, @main, @stable).
  • A same-repository action or reusable workflow is uses: $/<path>, never ./<path>: $/ resolves to the running commit, needs no checkout, and counts as pinned. It is github.com only, not GitHub Enterprise Server.

Permissions

Top-level permissions: contents: read. Widen only in the job that needs it: packages: write to push to GHCR, security-events: write for the SARIF upload, contents: write for gh release create, packages: read to pull a private image on the scheduled scan, id-token: write to attest a release (with attestations: write) or to publish through a registry's trusted publishing (release-supply-chain-conventions).

A called workflow can only keep or narrow the GITHUB_TOKEN scope of the job that calls it, never widen it. The release job that runs uses: $/.github/workflows/build.yaml therefore grants packages: write itself; without it the push is denied however build.yaml declares its own permissions.

Untrusted input

A workflow that runs code or text an outsider controls hands them the repository's token and secrets (Scorecard's Dangerous-Workflow check).

  • No ${{ }} inside a run: script, nor in actions/github-script's script:. The expression is pasted into the script before the shell parses it, so a pull request title or branch name holding "; curl … | sh runs as code. Pass the value through the step's env: and quote the variable:
        - name: print the pull request title
          env:
            TITLE: ${{ github.event.pull_request.title }}
          run: printf '%s\n' "$TITLE"
  • No pull_request_target trigger, and no workflow_run workflow that checks out or runs the triggering pull request's code. Both run a fork's code with the base repository's secrets and a write token. pull_request gives a fork read-only access and no secrets, which is all CI needs.
  • persist-credentials: false on every actions/checkout. Otherwise the token stays in .git/config for every later step, and in any artifact that uploads the workspace. gh reads GH_TOKEN from the step's env, so no job needs git's stored credentials.

Triggers per workflow

WorkflowTriggers
qualitypush to the default branch, pull_request, no paths
coveragepush to the default branch, pull_request, no paths
buildpush/pull_request with paths, workflow_dispatch and workflow_call with push and version inputs
securitypush to the default branch, pull_request, schedule, workflow_dispatch, no paths
chartpush of tags chart-*, workflow_dispatch
releasepush of tags v*
docspush to the default branch and pull_request with paths, workflow_dispatch
scorecardpush to the default branch, weekly schedule, branch_protection_rule

Path filters do not apply to tag, schedule, workflow_dispatch or workflow_call events, so don't write them there.

chart runs the same version drift guard as release before it packages (release-script-conventions).

A paths-filtered workflow must never be a required status check. When the filter skips it, the check never reports and the PR waits on it forever. Only the jobs of quality and, when it exists, security (never filtered) are required, in the default branch's ruleset (github-repo-settings). coverage is unfiltered but never required: it reports, it does not gate (ci-conventions).

coverage

One job on ubuntu-24.04, contents: read, so it runs the same on a fork's pull request. After the checkout, jdx/mise-action and the language's build cache (rust-cache with its save-if, below):

      - name: measure the coverage
        run: task coverage

      - name: write the summary to the job summary
        run: |
          {
            echo '## Test coverage'
            echo '```text'
            task --silent coverage:summary
            echo '```'
          } >> "$GITHUB_STEP_SUMMARY"

      - name: upload the HTML report
        uses: actions/upload-artifact@<40-char-sha>  # vX.Y.Z
        with:
          name: coverage-html
          path: <the language skill's HTML report directory>
          if-no-files-found: error
  • The summary goes in a text fence: the tools print aligned columns, which Markdown would reflow.
  • if-no-files-found: error: a report path that drifted from the tool's output otherwise uploads nothing, silently.

build and release

  • Multi-arch: a static matrix with amd64 on ubuntu-24.04 and arm64 on ubuntu-24.04-arm.
  • Tags and labels come from docker/metadata-action: labels on each per-arch build, tags in the manifest job, consumed from DOCKER_METADATA_OUTPUT_JSON by docker buildx imagetools create.
  • Scan before push: docker/build-push-action with load: true, then trivy image on the loaded image, then the same build again with a push by digest. That second build is a full cache hit, so the pushed layers are the ones that were scanned.
  • Layer cache: type=gha,scope=<target>-<arch>. An unscoped type=gha cache is shared, so the two arch jobs overwrite each other. cache-from unless the run pushes, since a publishing run restores no cache; cache-to from the default branch only, with mode=max, since mode=min drops the intermediate stages and with them the cargo chef cook layer. The push build still hits the scan build's layers, which the job's builder keeps:
    cache-from: >-
      ${{ !inputs.push
      && format('type=gha,scope={0}-{1}', matrix.target, matrix.platform.arch)
      || '' }}
    cache-to: >-
      ${{ github.ref == 'refs/heads/main'
      && format('type=gha,mode=max,scope={0}-{1}', matrix.target, matrix.platform.arch)
      || '' }}
  • release calls build through workflow_call with push: true, then gh release create "$TAG" --generate-notes gated on the tag containing no -. For a stable tag, pass --notes-start-tag with the previous stable tag.
  • On a public repository, manifest attests the image it tagged, and release attests and uploads its files, SBOM and attestation bundle (release-supply-chain-conventions).

Caches

What to cache and who saves it is ci-conventions. On GitHub:

  • A run restores its own ref's caches and the default branch's, nothing else. A PR can't read another PR's, and a tag run reads only main's.
  • A publishing run restores no build cache (ci-conventions). release and chart set a top-level cache-mode: none, which GitHub enforces on every job and on the workflows they call. A manual build with push escapes that cap, so it drops its cache-from itself (above).
  • Swatinem/rust-cache with save-if: ${{ github.ref == 'refs/heads/main' }}; without it every PR saves its own target/, hundreds of MB each.
  • The repository has a 10 GB quota with least-recently-used eviction, and evicts any entry unused for 7 days (the retention setting). Changing either is a repository setting, so it waits for the user's yes.
  • Diagnose with gh api repos/{owner}/{repo}/actions/cache/usage (total against the quota), gh cache list --ref <ref> (what a ref saved), and the run logs: rust-cache's full match: true|false, buildx's CACHED steps and exporting cache time.

docs and GitHub Pages

What the pipeline does is in starlight-conventions. On GitHub:

  • Pages source is "GitHub Actions": checking and switching it on is github-repo-settings' job. A custom domain is set in the repository's Pages settings, and the site's site/base follow it. No CNAME file is needed with an Actions deployment.
  • Two jobs. build checks out with fetch-depth: 0 (the release tags), runs jdx/mise-action for Node.js (mise-conventions), npm ci, and the versioned build, then actions/upload-pages-artifact with path: docs/dist on non-PR runs of the default branch only. deploy (needs: build, same condition) runs actions/deploy-pages in environment: github-pages with url: ${{ steps.deploy.outputs.page_url }}.
  • permissions: pages: write and id-token: write on deploy alone; the workflow stays contents: read.
  • The github-pages environment deploys from the default branch only, so a tag run cannot deploy. After a stable release, release dispatches the docs on the default branch, in a job that needs: the GitHub Release job (skipped for an rc, so the docs are too):
    docs:
      name: docs
      needs:
        - github-release
      permissions:
        actions: write
      runs-on: ubuntu-24.04
      steps:
        - name: rebuild the documentation site
          env:
            GH_TOKEN: ${{ github.token }}
            DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
          run: gh workflow run docs.yaml --repo "$GITHUB_REPOSITORY" --ref "$DEFAULT_BRANCH"
    A workflow_dispatch sent with GITHUB_TOKEN does start a run, unlike most events that token triggers.
  • docs is paths-filtered, so it is never a required check. The site's tests run in quality, in their own job.
  • No mise or npm cache: both are downloads.

.github/release.yaml

Always present when a release workflow exists. --generate-notes reads it. GitHub files a PR under the first category whose labels match, so Breaking changes comes first. A breaking PR also carries its usual feature/fix label, and only the order keeps it out of that section.

changelog:
  exclude:
    labels:
      - ignore-for-release
  categories:
    - title: Breaking changes
      labels:
        - breaking
    - title: Security
      labels:
        - security
    - title: Deprecations
      labels:
        - deprecation
    - title: Features
      labels:
        - feature
    - title: Performance
      labels:
        - performance
    - title: Fixes
      labels:
        - fix
    - title: Documentation
      labels:
        - documentation
    - title: Dependencies
      labels:
        - dependencies
    - title: Maintenance
      labels:
        - chore
    - title: Other changes
      labels:
        - "*"

Creating this file or changing its labels includes syncing the repo's labels to it (github-repo-settings), in the same change: gh pr create --label fails on a label the repo lacks.

Trivy on GitHub

  • aquasecurity/trivy-action, SHA-pinned. cache: true for the DB.
  • The gate step: exit-code: 1, severity: HIGH,CRITICAL, ignore-unfixed: true.
  • The reporting step: format: sarif, no exit-code, then github/codeql-action/upload-sarif with if: always() so a failed gate doesn't swallow the report. A pull request from a fork gets a read-only GITHUB_TOKEN, so the upload fails there; guard it to same-repository runs:
    if: >-
      always() && (github.event_name != 'pull_request'
      || github.event.pull_request.head.repo.full_name == github.repository)
  • Each SARIF upload has its own category (trivy-fs, trivy-image). Code scanning keys alerts on it. Two uploads sharing one replace each other, and the first scan's alerts get closed as "fixed".
  • The schedule:
    on:
      schedule:
        - cron: "23 4 * * *"
      workflow_dispatch:
    Scheduled workflows only run from the default branch, and GitHub disables them after 60 days without activity on a public repo, without telling anyone. A dormant repo that still ships an image needs it re-enabled from the Actions tab.

scorecard

A public repository runs OpenSSF Scorecard, which grades its supply-chain practices (pinned actions, token permissions, branch protection, a security policy, signed releases, …) and publishes the result. It is free on a public repository only; a private one has no scorecard.yaml.

name: scorecard

on:
  push:
    branches:
      - main
  schedule:
    - cron: "37 5 * * 1"
  branch_protection_rule:

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  analysis:
    runs-on: ubuntu-24.04
    permissions:
      contents: read
      security-events: write
      id-token: write
    steps:
      - name: check out the repository
        uses: actions/checkout@<40-char-sha>  # vX.Y.Z
        with:
          persist-credentials: false

      - name: run the Scorecard analysis
        uses: ossf/scorecard-action@<40-char-sha>  # vX.Y.Z
        with:
          results_file: results.sarif
          results_format: sarif
          publish_results: true

      - name: upload the results to code scanning
        if: always()
        uses: github/codeql-action/upload-sarif@<40-char-sha>  # vX.Y.Z
        with:
          sarif_file: results.sarif
          category: scorecard
  • branch_protection_rule re-grades as soon as a rule changes, and the weekly schedule keeps the activity-based checks current on a quiet repo. The 60-day rule for scheduled workflows (Trivy, above) applies.
  • publish_results: true sends the signed result to the Scorecard API, which is what the badge reads. The API then rejects a run whose workflow breaks its rules, so this file never gains: a top-level env or defaults, a write permission at workflow level, id-token: write on another job, and, in the analysis job, an env, a container, services, a runner other than a GitHub-hosted Ubuntu one, a run: step, or an action outside actions/checkout, actions/upload-artifact, github/codeql-action/upload-sarif, ossf/scorecard-action and step-security/harden-runner.
  • It never runs on a pull request, so it is never a required check.
  • The README carries its badge, on the badge line (readme-conventions):
    [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/<owner>/<repo>/badge)](https://scorecard.dev/viewer/?uri=github.com/<owner>/<repo>)
  • A finding is fixed in the repository — pin the action, narrow the token, add the SECURITY.md — never dismissed in code scanning to lift the score.

Concurrency

Every workflow has a top-level block:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
  • cancel-in-progress: true, literally. Never false, never an expression.
  • In a workflow_call workflow, hardcode the name: group: build-${{ github.ref }}. In a called run github.workflow resolves to the caller, so build would share release's group and cancel the very job waiting on it.
  • Key on github.ref, not github.head_ref. The latter is empty outside pull_request, and every push would collapse into one group.

Lint

The zizmor pre-commit hook, always, on a repo with workflows. It checks them against GitHub's schema and the rules above: untrusted input, persist-credentials, permissions, pinning, cache poisoning.

  - repo: https://github.com/zizmorcore/zizmor-pre-commit
    rev: <latest tag SHA>  # frozen: <latest tag>
    hooks:
      - id: zizmor
        args:
          - --offline
          - --strict-collection
          - --no-progress
  • --offline: with GH_TOKEN or GITHUB_TOKEN set, zizmor runs its online audits, and fails without network or on a revoked token. Offline, it needs neither. args replaces the hook's own --no-progress, hence repeating it.
  • --strict-collection: without it, a workflow that breaks the schema is skipped with a warning and the hook passes.
  • No actionlint beside it: it rejects $/ and cache-mode.
  • It also audits .pre-commit-config.yaml and .github/dependabot.yaml.
  • A finding is fixed, never silenced with a # zizmor: ignore[…] comment or a zizmor.yml rule on the agent's own authority (ci-conventions).

Never

  • Never start a workflow file with ---, and never quote "on".
  • Never use a bare branch/tag action ref.
  • Never put ${{ }} in a run: script, and never trigger on pull_request_target.
  • Never make a paths-filtered workflow, or coverage, a required check.
  • Never share one unscoped type=gha cache across architectures.
  • Never use ${{ github.workflow }} in the concurrency group of a reusable workflow.
  • Never let two SARIF uploads share a category.
  • Never deploy Pages from a tag run; dispatch the docs on the default branch.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.