CI на GitHub Actions

Пишет и чинит workflow GitHub Actions: триггеры, кеш, матрицы, concurrency, минимальные permissions, секреты, SHA-пины и разбор логов. Используйте при добавлении, правке или отладке CI.

DevOpsПак: DevOps111 строкgithub-actions-ci

Установка

Выполните одну команду — она сохранит SKILL.md в папку скиллов агента. Перезапустите агента, и он подхватит скилл сам.

Claude Code — macOS, Linux
mkdir -p ~/.claude/skills/github-actions-ci && curl -fsSL https://anymodel.org/en/skills/devops/github-actions-ci/SKILL.md -o ~/.claude/skills/github-actions-ci/SKILL.md
Codex, Cursor — macOS, Linux
mkdir -p ~/.agents/skills/github-actions-ci && curl -fsSL https://anymodel.org/en/skills/devops/github-actions-ci/SKILL.md -o ~/.agents/skills/github-actions-ci/SKILL.md
Claude Code — Windows PowerShell
New-Item -ItemType Directory -Force "$HOME\.claude\skills\github-actions-ci" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/devops/github-actions-ci/SKILL.md -UseBasicParsing -OutFile "$HOME\.claude\skills\github-actions-ci\SKILL.md"
Codex, Cursor — Windows PowerShell
New-Item -ItemType Directory -Force "$HOME\.agents\skills\github-actions-ci" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/devops/github-actions-ci/SKILL.md -UseBasicParsing -OutFile "$HOME\.agents\skills\github-actions-ci\SKILL.md"

Другой агент: сохраните файл в его папку скиллов или дайте ему ссылку на файл: https://anymodel.org/en/skills/devops/github-actions-ci/SKILL.md

SKILL.md

Исходник

GitHub Actions CI

Create or repair workflows in .github/workflows/. Keep them fast, deterministic and least-privilege. Read the existing workflows and the project's build/test commands first; reuse the commands developers already run locally.

Workflow for a new or changed pipeline

  1. Find the real commands: package.json scripts, Makefile, pyproject.toml, tox.ini. The CI should call the same commands.
  2. Choose triggers deliberately (see below).
  3. Write the smallest workflow that builds and tests. Add caching, matrix and extras only when they pay off.
  4. Validate the YAML (actionlint if installed, otherwise a YAML parser) before pushing.
  5. Do not push or open a PR without the user's go-ahead; report what to look at in the first run.

Skeleton

name: ci
on:
  pull_request:
  push:
    branches: [main]

concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@<full-commit-sha> # v4.x.x
      - uses: actions/setup-node@<full-commit-sha> # v4.x.x
        with:
          node-version-file: .nvmrc
          cache: npm
      - run: npm ci
      - run: npm test

Look up the current commit SHA of each action's release tag; never invent one.

Rules

Triggers

  • pull_request for checks on contributions; push to the default branch for post-merge work; workflow_dispatch for manual runs; schedule for nightly jobs.
  • Use paths: / paths-ignore: to skip unrelated changes, but remember required checks that are skipped can block merging.
  • Never use pull_request_target to run code from a fork. It runs with secrets and write access.

Permissions

  • Set top-level permissions: contents: read and widen per job only where needed (pull-requests: write, packages: write, id-token: write).
  • Prefer OIDC (id-token: write) with a cloud role over long-lived cloud keys in secrets.

Pinning actions

  • Pin third-party actions to a full commit SHA with the version in a trailing comment. Tags can be moved by the action's owner.
  • First-party actions/* may use a version tag if the team accepts that; say which policy you applied.
  • Enable Dependabot/Renovate for github-actions so pins get updated.

Caching

  • Use the built-in cache: of the setup actions (npm, pip, gradle, go) keyed on the lock file.
  • For custom caches use actions/cache with a key containing hashFiles('**/lockfile') and a restore-keys fallback.
  • Never cache secrets, .env files or credentials.

Matrix

  • Use strategy.matrix for language versions or OS only when the project supports them. Set fail-fast: false when you want all results.
  • Keep the matrix small; every cell costs minutes.

Concurrency and cost

  • Use a concurrency group so new pushes cancel stale PR runs. Do not cancel deploy jobs on the default branch.
  • Set timeout-minutes on every job to avoid six-hour hangs.

Secrets

  • Reference secrets only through ${{ secrets.NAME }} in env: of the step that needs them, not at workflow level.
  • Never echo a secret or run with set -x around it. Never pass secrets in command-line arguments when an env var works.
  • Secrets are not available to workflows from forks; design the check so it still passes without them or is skipped clearly.
  • Untrusted input (github.event.pull_request.title, branch names) must not be interpolated directly into run:. Pass it through env: and quote it.

Debugging a failing run

gh run list --limit 5
gh run view <run-id> --log-failed
gh run view <run-id> --json jobs --jq '.jobs[] | select(.conclusion=="failure") | .name'
gh run rerun <run-id> --failed      # only after the user agrees
  1. Read the first real error in the failed step, not the last line of the log.
  2. Decide: code bug, flaky test, environment difference (OS, Node/Python version, missing env var), cache poisoning, or permissions.
  3. Reproduce locally with the same command and versions when possible.
  4. For cache suspicion, change the cache key once and rerun rather than guessing.

Output format

Report: the workflow files changed, what each change does and why, how it was validated (linter, local run), and the risks (for example "requires repository setting X" or "pins need SHAs verified").

Pitfalls

  • Do not add continue-on-error: true to hide a failure.
  • Do not disable or delete tests to make CI green.
  • Do not grant write-all permissions to fix a 403; find the one permission needed.
  • ubuntu-latest changes over time; pin a version (ubuntu-24.04) if reproducibility matters.
  • YAML gotchas: unquoted on, versions like 3.10 parsed as 3.1; quote versions.

Source: AnyModel skills catalog · License: CC BY 4.0

Подключить через AnyModel API

Скилл работает на той модели, которую использует агент. Подключите Claude Code, Codex или Cursor к AnyModel и запускайте его на Claude, GPT, Gemini и других моделях по одному ключу — оплата за токены, без подписки.

Ещё из пака DevOps

Ревью Dockerfile

Пишет и проверяет Dockerfile: закреплённые базовые образы, multi-stage, порядок слоёв для кеша, не-root пользователь, .dockerignore. Используйте при создании или ревью Dockerfile и образов.

Ревью манифестов Kubernetes

Проверяет манифесты Kubernetes и Helm values: ресурсы, пробы, securityContext, теги образов, PodDisruptionBudget, стратегию выкатки. Используйте при написании или ревью K8s YAML и чартов.

Разбор инцидента

Ведёт разбор инцидента на проде: оценка влияния, сначала стабилизация откатом или флагом, таймлайн, коммуникация, постмортем без поиска виноватых. Используйте при падении, ошибках на проде и для постмортема.

Чек-лист релиза

Проводит проверки до и после релиза: миграции, конфиг и env, флаги, обратная совместимость, мониторинг, план отката, release notes. Используйте перед выкаткой или тегом релиза.

Аудит секретов и конфигурации

Находит захардкоженные секреты и конфиг, переносит их в переменные окружения, ведёт .env.example, проверяет .gitignore и историю git. Используйте при аудите секретов или перед публикацией репозитория.