Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

gha-best-practices

БесплатноБез исполняемых скриптовНе проверен

GitHub Actions workflow rules: triggers, draft guards, path filters, concurrency, permissions, secrets, action pinning, timeouts, caching, artifacts, checkout…

anchildress1от anchildress1★ 68 звёзд на GitHub

Об этом скилле

Apply every rule to each workflow file you create or modify. Fix existing violations in the same edit, unasked.

Triggers

Declare explicit pull_request types. Bare pull_request: (implicit opened, synchronize, reopened) fires on drafts and never on ready_for_review, so a draft-skipped job never runs when the PR is marked ready.

on:
  pull_request:
    types: [opened, reopened, synchronize, ready_for_review]

Skip drafts on every pull_request job:

jobs:
  build:
    if: github.event.pull_request.draft == false

Mixed-trigger workflow → add the escape clause, or the job never runs on push:

    if: github.event.pull_request.draft == false || github.event_name != 'pull_request'

Path filters

  • Filter push and pull_request with paths-ignore for docs-only changes.
  • paths and paths-ignore are mutually exclusive on one event.
  • Never filter out a path the build reads: workflow files, lockfiles, build-time imports. docs/** and **/*.md are safe.
  • Always pair path filters with workflow_dispatch; manual runs ignore filters.
on:
  push: ...
  pull_request:
    types: [opened, reopened, synchronize, ready_for_review]
    paths-ignore:
      - "**/*.md"
      - "docs/**"
  workflow_dispatch:

Never make a path-filtered workflow a required status check. A filtered-out workflow never reports, so the required check stays Pending and blocks merge. (A skipped job reports Success; a skipped workflow reports nothing.) Pick one:

Need Do
Required check No path filter on it
Path filter Check stays optional
Both One unfiltered workflow: a changes job detects paths, the required job gates on its output with if: and reports Success when skipped
jobs:
  changes:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    permissions:
      contents: read
      pull-requests: read
    outputs:
      code: ${{ steps.filter.outputs.code }}
    steps:
      - name: Checkout
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - name: Detect changed paths
        id: filter
        uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
        with:
          predicate-quantifier: every
          filters: |
            code:
              - '**'
              - '!docs/**'
              - '!**/*.md'
  build:
    needs: changes
    if: needs.changes.outputs.code == 'true'

Never use a same-named second workflow with the inverse filter: a PR touching both paths runs both, they share the concurrency group and cancel each other, and required checks match job names, not workflow names.

Concurrency

Every workflow:

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

Permissions

  • Job level, never workflow level. Only what the job uses.
  • pull-requests: write only when the job posts comments or status checks.
  • Never write-all. Never omit the block; omission inherits broad defaults.
jobs:
  test:
    permissions:
      contents: read

Secrets

Step-scoped only. Job- or workflow-level env exposes the secret to every step, third-party actions included.

# WRONG
jobs:
  deploy:
    env:
      API_KEY: ${{ secrets.API_KEY }}

# CORRECT
    steps:
      - name: Deploy
        env:
          API_KEY: ${{ secrets.API_KEY }}
        run: ./deploy.sh
  • Use the default GITHUB_TOKEN. A PAT or GitHub App token only when the user asks for one.
  • Never print a secret. Mask runtime-derived sensitive values: echo "::add-mask::$TOKEN".
  • Never guard with if: env.SECRET != ''. Let the step fail; skipping hides a config error behind a green run.

secrets: inherit

Never by default. It passes the callee every repo/org secret, including ones added later.

# WRONG
jobs:
  deploy:
    uses: ./.github/workflows/deploy.yml
    secrets: inherit

# CORRECT
jobs:
  deploy:
    uses: ./.github/workflows/deploy.yml
    secrets:
      GCP_SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT }}
      SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  • Callee declares each secret under on.workflow_call.secrets with required:, so a missing one fails at call time instead of arriving as an empty string.
  • Never pass GITHUB_TOKEN; the callee gets its own, scoped by its permissions.
  • Prefer OIDC where the provider supports it (Google Cloud, AWS, Azure).
  • inherit allowed only when caller and callee share a repo and the needed set varies per caller. Justify it inline.

Action pinning

Resolve every version at write time, never from memory or an example:

tag=$(gh api repos/<owner>/<repo>/releases/latest --jq .tag_name)
gh api repos/<owner>/<repo>/commits/$tag --jq .sha

Pin every action, actions/* included, to the full commit SHA plus a version comment. Never a mutable tag (@latest, @main, @v7): a moved tag runs new code with the job's to

Полный SKILL.md на GitHub

Установить gha-best-practices в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл gha-best-practices?

GitHub Actions workflow rules: triggers, draft guards, path filters, concurrency, permissions, secrets, action pinning, timeouts, caching, artifacts, checkout depth, installs, step naming, actionlint, Dependabot. Load BEFORE creating or editing any file under `.github/workflows/` or `.github/actions/` (ci.yml, codeql.yml, release-please.yml, reusable workflows, composite actions), including a one-line change. Trigger on: adding or changing a job, step, trigger, `permissions` block, matrix, or `env`; "add a workflow", "fix CI", "CI is failing", "add a job", "add a step", "pin this action", "add workflow_dispatch", "run it on PRs", "cache the install", "upload the artifact", "why did CI not run", "add dependabot"; scaffolding CI for a new repo; reviewing a diff that touches a workflow file, even when the user never says "Actions".

Как установить скилл gha-best-practices?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл gha-best-practices запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить gha-best-practices с