github-actions – skill Lập trình cho agent AI
Xây dựng, kiểm thử và triển khai ứng dụng bằng quy trình GitHub Actions.
Cài skill github-actions bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/github-actions-3d742.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /github-actions – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/github-actions-3d742.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $github-actions – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/github-actions-3d742.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /github-actions – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/github-actions-3d742.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /github-actions – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
GitHub Actions
Automate software workflows directly in your GitHub repository with GitHub Actions.
When to Use This Skill
Use this skill when:
- Setting up CI/CD pipelines for GitHub repositories
- Automating build, test, and deployment workflows
- Creating reusable workflow components
- Configuring self-hosted runners
- Managing workflow secrets and variables
- Debugging failed workflow runs
Scope and Fragment Prerequisites
Examples are independent YAML fragments, not a complete deployable pipeline. Each new job needs its own checkout, tool setup, locked dependency installation and artifact transfer; jobs do not share a working directory. Review untrusted event inputs, least-privilege permissions, protected environments and secret exposure before adoption. Image push, deployment and runner registration require authorization.
Prerequisites
- GitHub repository with write access
- Understanding of YAML syntax
- For self-hosted runners: server with Docker (optional)
Workflow File Structure
Workflows are defined in .github/workflows/ directory:
name: CI Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- run: npm testCommon Triggers
Push and Pull Request
on:
push:
branches: [main]
paths:
- 'src/**'
- 'package.json'
pull_request:
branches: [main]Scheduled Runs
on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTCManual Dispatch
on:
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'staging'
type: choice
options:
- staging
- productionJob Configuration
Matrix Builds
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22, 24]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm testJob Dependencies
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: npm run build
test:
needs: build
runs-on: ubuntu-latest
steps:
- run: npm test
deploy:
needs: [build, test]
runs-on: ubuntu-latest
steps:
- run: ./deploy.shEnvironment Protection
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: production
url: https://example.com
steps:
- run: ./deploy.shSecrets and Variables
Using Secrets
steps:
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: aws s3 sync ./dist s3://my-bucketUsing Variables
steps:
- name: Build
env:
API_URL: ${{ vars.API_URL }}
run: npm run buildCaching Dependencies
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-Artifacts
Upload Artifacts
- uses: actions/upload-artifact@v4
with:
name: build-output
path: dist/
retention-days: 5Download Artifacts
- uses: actions/download-artifact@v4
with:
name: build-output
path: dist/Docker Builds
jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: user/app:latestReusable Workflows
Define Reusable Workflow
# .github/workflows/reusable-deploy.yml
name: Reusable Deploy
on:
workflow_call:
inputs:
environment:
required: true
type: string
secrets:
deploy_key:
required: true
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Report selected environment
env:
DEPLOY_ENVIRONMENT: ${{ inputs.environment }}
run: printf 'Deploying to %s\n' "$DEPLOY_ENVIRONMENT"Call Reusable Workflow
jobs:
deploy-staging:
uses: ./.github/workflows/reusable-deploy.yml
with:
environment: staging
secrets:
deploy_key: ${{ secrets.STAGING_KEY }}Self-Hosted Runners
Register Runner
Use the selected repository's current runner setup instructions. Verify the official
release checksum before extracting or executing it, choose the intended architecture,
and use a short-lived registration token without printing it. Do not use a historical
hardcoded runner version. Treat self-hosted runner access as host code execution:
never run untrusted fork PR code on a persistent privileged runner.
Use Self-Hosted Runner
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4Debugging Workflows
Enable Debug Logging
Set repository secrets:
ACTIONS_RUNNER_DEBUG:trueACTIONS_STEP_DEBUG:true
Debug Step
Print only explicitly selected non-secret fields needed for the failure. Full GitHub/job
context dumps can reveal tokens and sensitive metadata; do not copy them into logs.
Common Issues
Issue: Workflow Not Triggering
Problem: Workflow doesn't run on push/PR
Solution: Check branch filters, path filters, and ensure workflow file is on the default branch
Issue: Permission Denied
Problem: Actions can't push or create PRs
Solution: Configure permissions in workflow or update repository settings
permissions:
contents: write
pull-requests: writeIssue: Cache Not Restoring
Problem: Cache misses despite existing cache
Solution: Verify cache key matches exactly, check runner OS
Best Practices
- Pin reviewed third-party actions to full immutable commit SHAs; example tags below describe interfaces, not production trust pins
- Use caching for dependencies to speed up builds
- Minimize secrets exposure with environment scoping
- Use matrix builds for cross-platform testing
- Required tests and security checks must fail the job when they fail. Use
continue-on-erroronly for declared nonblocking advisory checks and report their actual outcome. - Keep workflows DRY with reusable workflows and composite actions
Related Skills
- gitlab-ci (
gitlab-ci) - GitLab CI/CD alternative - docker-management (
docker-management) - Container builds - semantic-versioning (
semantic-versioning) - Automated releases
Limitations
- Guidance executes against real environments: confirm target, blast radius, and rollback plan before applying anything.
- Never deploy to production without explicit approval. Docs-only import: upstream scripts and templates not bundled.
Example
git status && git diff --stat
gh run view <actual-run-id> --log-failed> Adapted from [BagelHole/DevOps-Security-Agent-Skills](https://github.com/BagelHole/DevOps-Security-Agent-Skills) (MIT); frontmatter, When to Use/Limitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.
Skill liên quan
- github-actions-advanced – Thiết kế, gỡ lỗi và củng cố quy trình CI/CD GitHub Actions, bao gồm reusable workflows…
- github-actions-debugger – Kỹ năng chuyên biệt để chẩn đoán, phân tích và sửa các quy trình GitHub Actions bị lỗi…
- github-actions-templates – Các mẫu quy trình GitHub Actions sẵn sàng cho production để kiểm thử, build và triển…
- github-automation – Thao tác với issues, pull requests, branches, checks, workflows và quyền trên GitHub qua…
- github-issue-creator – Biến nhật ký lỗi, ảnh chụp màn hình, ghi âm giọng nói và báo lỗi sơ sài thành GitHub…
- senior-qa – Tạo unit test, integration test và E2E test cho ứng dụng React/Next.js. Quét component…
- github-presence – Khi người dùng muốn tối ưu hồ sơ GitHub, README hoặc khả năng hiển thị dự án. Các cụm…
- go – Hướng dẫn code siêu chuẩn theo ngôn ngữ dành riêng cho Go.