github-actions
npx skills add https://github.com/dalestudy/skills --skill github-actions
Agent 安装分布
Skill 文档
GitHub Actions
주ì ì¬í (Anti-patterns)
1. ì¤ëë ë²ì ì¬ì©
# â ì¤ëë ë²ì - ê°ì¥ íí ì¤ì
uses: actions/checkout@v4 # v6ê° ìµì ì¸ ê²½ì°
# â
ìµì ë©ì´ì ë²ì (gh apië¡ íì¸ í ì¬ì©)
uses: actions/checkout@v6
ìµì ë²ì ìì ì ê³µíë ì±ë¥ ê°ì ê³¼ ë³´ì í¨ì¹ë¥¼ ëì¹ì§ ìëë¡ í©ëë¤.
ë²ì íì¸ ëª ë ¹ì´:
gh api repos/{owner}/{repo}/releases/latest --jq '.tag_name'
# ìì
gh api repos/actions/checkout/releases/latest --jq '.tag_name'
gh api repos/oven-sh/setup-bun/releases/latest --jq '.tag_name'
ì°¸ê³ : ë³´ì ë¯¼ê° íê²½ì´ë ì 뢰ë ë®ì ìëíí° ì¡ì ì SHA í¼ë(
@a1b2c3...)ì ê³ ë ¤.
2. 민ê°ì ë³´ íëì½ë©
# â íëì½ë© - ë³´ì ìí
env:
API_KEY: "sk-1234567890"
DATABASE_PASSWORD: "mypassword123"
# â
secrets ì¬ì©
env:
API_KEY: ${{ secrets.API_KEY }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
ë¹ë°ë²í¸ë API Keyì ê°ì ë¯¼ê° ì ë³´ê° ê·¸ëë¡ ë ¸ì¶ëì´ ë³´ì ì¬ê³ ë¡ ì´ì´ì§ ì ììµëë¤. ë³´ì ì ì¤ìí ì ë³´ë ë°ëì ì ì¥ìë ì¡°ì§ì ìí¬ë¦¿ì¼ë¡ ì ì¥í´ëê³ ì½ì´ ìì¼í©ëë¤.
ì°¸ê³ : Using secrets
3. ì ë ¥ê° ì¸ì ì ì·¨ì½ì
# â ì¸ì ì
ì·¨ì½ - github.event ì§ì ì¬ì©
run: echo "${{ github.event.issue.title }}"
run: gh issue comment ${{ github.event.issue.number }} --body "${{ github.event.comment.body }}"
# â
íê²½ë³ìë¡ ì ë¬íì¬ ì¸ì ì
ë°©ì§
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
echo "$ISSUE_TITLE"
gh issue comment ${{ github.event.issue.number }} --body "$COMMENT_BODY"
ì ìì ì¸ ì¬ì©ìê° ì´ì ì 목ì´ë ì½ë©í¸ì ì ¸ ëª ë ¹ì´ë¥¼ 주ì í ì ììµëë¤.
ì°¸ê³ : Script injections
4. pull_request_target ì´ë²¤í¸ ì¤ì©
# â ï¸ ìí - í¬í¬ì ì½ë를 ì 뢰ë 컨í
ì¤í¸ìì ì¤í
on: pull_request_target
steps:
- uses: actions/checkout@v{N}
with:
ref: ${{ github.event.pull_request.head.sha }} # ìí!
pull_request_target ì´ë²¤í¸ë í¬í¬ì PRììë ìí¬ë¦¿ì ì ê·¼ ê°ë¥í©ëë¤. í¬í¬ ì½ë를 ì²´í¬ììíë©´ ì
ì± ì½ëê° ì¤íë ì ììµëë¤.
ì°¸ê³ : pull_request_target
5. ì¬ì ì¤ì¹ë ë구ì ì¤ë³µ ì¤ì
# â ë¶íìí setup - node, npm, npxë ì´ë¯¸ ì¤ì¹ë¨
steps:
- uses: actions/setup-node@v{N}
- run: npx some-command
# â
ë°ë¡ ì¬ì©
steps:
- run: npx some-command
- run: python script.py
- run: docker build .
ì¤ë³µ ì¤ì¹ë ìí¬íë¡ì° ì¤í ìê°ì ëë¦¬ê³ ë¶íìí ë¤í¸ìí¬ ìì²ì ë°ììíµëë¤.
주ì ì¬ì ì¤ì¹ ë구: Node.js, npm, npx, Python, pip, Ruby, gem, Go, Docker, git, gh, curl, wget, jq, yq
주ì 미ì¤ì¹ ë구: Bun, Deno, Rust, Zig, pnpm, Poetry, Ruff
ì¬ì ì¤ì¹ë ë구 íì¸:
- Ubuntu: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
- macOS: https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
- Windows: https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
ëª¨ë² ì¬ë¡ (Best Practices)
ìµì ê¶í ìì¹
ê¶íì ê°ë¥í íì ë 벨ì ì ì¸. ë²ì를 ì¢ê² ì ì§:
# â
ê¶í ë²ì: workflow > job > step (ì¢ììë¡ ì¢ì)
jobs:
build:
permissions:
contents: read # job ë 벨ìì íìí ê¶íë§
ê¶ì¥ ìí¬íë¡ì° 구조
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# ë²ì ì gh apië¡ íì¸ í ì¬ì©
- uses: actions/checkout@v{N}
- name: Setup Bun
uses: oven-sh/setup-bun@v{N}
ì주 ì¬ì©ëë ì´ë²¤í¸
on:
push: # í¸ì ì
branches: [main]
pull_request: # PR ìì±/ì
ë°ì´í¸ ì
branches: [main]
workflow_dispatch: # ìë ì¤í
schedule: # ì¤ì¼ì¤ ì¤í
- cron: "0 0 * * 1" # 매주 ììì¼ 00:00 UTC
release: # ë¦´ë¦¬ì¤ ìì± ì
types: [published]
workflow_call: # ë¤ë¥¸ ìí¬íë¡ì°ìì í¸ì¶
ì주 ì¬ì©ëë ê¶í
permissions:
contents: read # CI (ë¹ë/í
ì¤í¸), ì½ë ì²´í¬ìì
contents: write # 커ë°/í¸ì
pull-requests: write # PR ì½ë©í¸ ë´
issues: write # ì´ì ì½ë©í¸
packages: write # í¨í¤ì§ ë°°í¬ (contents: writeì í¨ê»)
id-token: write # OIDC í´ë¼ì°ë ì¸ì¦ (contents: readì í¨ê»)
ì주 ì¬ì©ëë ì¡ì
# ë²ì ì gh api repos/{owner}/{repo}/releases/latest --jq '.tag_name'ì¼ë¡ íì¸
steps:
- uses: actions/cache@v{N} # ìì¡´ì± ìºì±
- uses: actions/checkout@v{N} # ì½ë ì²´í¬ìì
- uses: actions/download-artifact@v{N} # ìí°í©í¸ ë¤ì´ë¡ë
- uses: actions/upload-artifact@v{N} # ìí°í©í¸ ì
ë¡ë
- uses: oven-sh/setup-bun@v{N} # Bun ì¤ì