github-actions
Use when writing or reviewing .github/workflows YAML files or debugging CI. GitHub Actions security and best practices - SHA-pinned actions, least-privilege permissions, script injection via PR context, pull_request_target dangers, secrets and OIDC, cache poisoning, matrix and artifacts.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- github-actions
- triggers
- [ "user", "model" ]
- description
- Use when writing or reviewing .github/workflows YAML files or debugging CI. GitHub Actions security and best practices - SHA-pinned actions, least-privilege permissions, script injection via PR context, pull_request_target dangers, secrets and OIDC, cache poisoning, matrix and artifacts.
- allowed-tools
- [ "read", "exec", "grep", "edit" ]
03 SKILL.md 正文
GitHub Actions
CI/CD is the most common place to leak secrets and take supply-chain attacks: the YAML is code that runs with credentials. Editing .github/workflows/ requires extra review.
Triggers and scope
on: push/pull_request/workflow_dispatch/schedule/workflow_call- the trigger defines who can run it and with what context.pull_requestfrom a fork runs WITHOUT secrets (safe-ish);pull_request_targetruns with secrets + write token ON FORK CODE = the most dangerous trigger in Actions. Only with restrictedtypes:+ checkout of the base (never the head) + minimal permissions, or anenvironment:with manual review.workflow_run/workflow_dispatchwith inputs: validate them (type: choicewhen possible).paths:/branches:filters so a README change does not run the whole CI.concurrency:to cancel redundant runs (cancel-in-progress: trueon PRs).
Permissions (the default is dangerous)
- The default
GITHUB_TOKENhas broad permissions. ALWAYS declarepermissions:at top level or per job -contents: readis the floor; add only what is needed (pull-requests: write,packages: write). - Job needing no token:
permissions: {}. secrets: inheritin a reusable workflow leaks everything - pass secrets explicitly.
Script injection (the classic bug)
- NEVER interpolate PR context into
run::run: echo "${{ github.event.pull_request.title }}"- the title is attacker-controlled,$(rm -rf ~)executes. Correct: env var (env: TITLE: ${{ ... }}+echo "$TITLE") orgithub-scriptwith the value as an argument. - Dangerous contexts:
github.event.issue.title,.body,pull_request.title,.head.ref,commits.*.message,github.head_ref. Anything an external user controls does NOT go inline intorun:. - Same rule for
env:/with:interpolated directly intoscript:ofactions/github-script.
Third-party actions (supply chain)
- Pin by commit SHA, not by tag:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2. Tags are mutable - the owner can re-point them to malicious code (has happened to popular actions). - Trust only official orgs (
actions/*,github/*) or audited vendors; an obscure 3-star action running with your token is risk. allowed-actionsat repo/org level restricts what runs.- Dependabot for actions updates SHAs (
.github/dependabot.ymlwithpackage-ecosystem: github-actions).
Secrets and OIDC
- Secrets via
${{ secrets.X }}- neverecho(goes to the log); the runner masks, but formatting breaks masking. - OIDC (
id-token: write+ aws/azure/gcp role) replaces long-lived cloud keys - preferable to static secrets. environment:with required reviewers for deploy/prod jobs.- Secrets into a
run:step indirectly via env (env: KEY: ${{ secrets.KEY }}), never inline in the command (the log shows the command, not the env). ACTIONS_STEP_DEBUGlogs more - do not enable on public repos with secrets.
Cache and artifacts
actions/cachekeyed by lockfile (hashFiles('**/package-lock.json')) +restore-keysfallback.- Cache poisoning: can a fork
pull_requestwrite to the shared cache? No - PR cache is isolated from the base branch (butpull_request_targetis not). Know the difference. - Downloading artifacts from another workflow run (
dawidd6/action-download-artifact) is a surface - untrusted PR artifacts must not go straight into a release. - Shorter
retention-daysfor artifacts holding sensitive data.
Jobs and matrix
strategy.matrixfor multi-version/os;fail-fast: falsewhen you want all results.timeout-minuteson every job (default 6h = runaway runner bill).if:with explicitsuccess()/failure()/always()- default is "only if previous passed".outputsbetween jobs vianeeds- never pass secrets through outputs (goes to metadata log).services:(postgres/redis) for real integration tests instead of mocks.runs-on: ubuntu-latestok; self-hosted runner on a public repo = anyone who opens a PR runs code on your machine - NEVER.
Reusable workflows and composite actions
workflow_callwith declaredinputs/secrets; caller passes explicitly (notsecrets: inherit).- Composite action (
action.yml) for repeated steps; same injection care inrun:.
Common review findings
pull_request_targetwithout restriction/protected environment.${{ github.event.* }}insiderun:(injection).- Missing
permissions:(full-access token). - Floating-tag action (
@v4,@main) instead of SHA. secrets: inheritin reusable workflows.- Secret echoed/printed or passed inline in a command.
- Self-hosted runner on a public repo.
continue-on-errorhiding real failure in a required check.- Checkout of
github.event.pull_request.head.shaunderpull_request_target(runs fork code with secrets). - CI edited without the task requiring it (change in workflow needs justification in the report).
Cascade
- Secrets in repo/CI:
securityskill. - Pinned versions of actions/deps: repository pinning rules (versions >7 days published).
- CI files are a protected zone: justify edits in the change report.
- Red CI triage and flow selection:
git-github-adaptive-engineeringorchestrates (flow 5, CI self-healing); this skill owns the workflow YAML rules.
04 同仓库更多 Skills
montador-de-ideias
Use when assembling, expanding, or elevating a raw project idea or initial prompt into an ultra-detailed, first-principles dossier and compiled master prompt with journalistic OSINT market research, Tech Lead and Staff Architect justifications, atomic and modular hardening/optimization, and high-impact contact surfaces.
git-github-adaptive-engineering
Use when any task touches git history, GitHub issues/PRs/releases/CI, repo governance, or branch and merge decisions. Runs the Fase Zero situational-awareness battery, picks one of five delivery flows via the adaptive decision engine, and enforces commit/PR information-density standards. Orchestrates the gh, git-workflows, github-actions, pr, and debug/finish skills.
adaptive-agenda-calendar-routine-engine
Use when planning or executing work across hours, days, weeks, or sprints. Turns the calendar into a strict time-blocked agenda (HH:MM-HH:MM blocks carrying a routine profile, expected inputs, and a handoff output artifact), runs the 5-stage cognitive flow (Radar and Hunt -> Triage plus Steve Jobs conception -> workbench manifest -> >=32-cycle loop -> Close plus Open-Minded Scrum), and unfolds macro calendar milestones into micro agenda blocks through extensions/gcal/wrapper.py.
demo
Use when demonstrating a skill in a fixture project.
duplicate-skill
Use when testing duplicate skill name detection.
duplicate-skill
Use when testing duplicate skill name detection.