Skip to content

Latest commit

Β 

History

History
106 lines (85 loc) Β· 6.65 KB

File metadata and controls

106 lines (85 loc) Β· 6.65 KB

🌟 HackaLearn Korea 2021 GitHub Actions Workshop

ν•΄μΉ΄λŸ° 코리아 2021 κΉƒν—™ μ•‘μ…˜ μ›Œν¬μƒ΅ 2021.08.02 8PM KST

πŸš€ Hands-on Demo Contents

1. Customize GitHub Actions with Docker

Dockerλ₯Ό ν™œμš©ν•œ μ»€μŠ€ν…€ GitHub Actions λ§Œλ“€κΈ°

2. Automatize Slack Message with GitHub Actions

GitHub Actionsλ₯Ό ν™œμš©ν•œ μžλ™ Slack Message 전솑 Workflow λ§Œλ“€κΈ°


Uses: Go Docker GitHub Actions

/.github
β”œβ”€β”€ actions
β”‚   └── hello-team
|       β”œβ”€β”€ action.yml
|       β”œβ”€β”€ main.go
|       └── Dockerfile
└── workflows
    └── hello-team.yml

Workflowλ‚΄ action의 input 값을 Docker envλ₯Ό 톡해 GitHub Actions input variable둜 받아와 Go main codeμ—μ„œ 좜λ ₯ν•˜λŠ” actionμž…λ‹ˆλ‹€.

Uses: Python Docker GitHub Actions

/.github
β”œβ”€β”€ actions
β”‚   └── random-joke
|       β”œβ”€β”€ action.yml
|       β”œβ”€β”€ src
|       |   └── main.py
|       β”œβ”€β”€ requirements.txt
|       └── Dockerfile
└── workflows
    └── random-joke.yml

action을 κ΅¬μ„±ν•˜λŠ” python main codeμ—μ„œ μ™ΈλΆ€ APIλ₯Ό ν˜ΈμΆœν•΄ json 값을 λ°˜ν™˜ν•˜μ—¬ λžœλ€ν•˜κ²Œ λ°°μ—΄ 값을 골라 좜λ ₯ν•˜λŠ” actionμž…λ‹ˆλ‹€. λ˜ν•œ GitHub Actions μ•ˆμ— λ‹€λ₯Έ variable을 output으둜 μƒμ„±ν•˜μ—¬ λ‹€λ₯Έ actionμ—μ„œ λ³€μˆ˜ 값을 μž¬μ‚¬μš©ν•  수 μžˆλ„λ‘ κ΅¬μ„±ν•©λ‹ˆλ‹€.

Uses: JavaScript Docker GitHub Actions

/.github
β”œβ”€β”€ actions
β”‚   └── issue-maker
|       β”œβ”€β”€ action.yml
|       β”œβ”€β”€ src
|       |   └── index.js
|       β”œβ”€β”€ package.json
|       └── Dockerfile
└── workflows
    └── make-issue.yml

λ‹€λ₯Έ action(1.2 Random Joke Action)μ—μ„œ λ°›μ•„μ˜¨ 값을 ν™œμš©ν•΄, κ·Έ 값을 GitHub Repository λ‚΄ Issue μƒμ„±μœΌλ‘œ markdown ν˜•μ‹μœΌλ‘œ λ°˜ν™˜ν•΄ 이미지λ₯Ό ν¬ν•¨ν•œ Issue 글을 μžλ™μœΌλ‘œ μž‘μ„±ν•©λ‹ˆλ‹€. GitHub Repositoryλ₯Ό μ§μ ‘μ μœΌλ‘œ μ ‘κ·Όν•˜λŠ” action이기 λ•Œλ¬Έμ—, ${{ secrets.GITHUB_TOKEN }} 이 ν•„μˆ˜μ μœΌλ‘œ ν•„μš”ν•©λ‹ˆλ‹€.

Uses: GitHub Actions GitHub Slack

/.github
└── workflows
    └── slack-message.yml

GitHub λ§ˆμΌ“ν”Œλ ˆμ΄μŠ€μ— 곡개된 action을 ν™œμš©ν•˜μ—¬, GitHub Repository에 Pull Requestκ°€ μƒμ„±λ˜μ—ˆμ„ 경우, Slack에 μžλ™μœΌλ‘œ λ©”μ‹œμ§€λ₯Ό μ „μ†‘ν•©λ‹ˆλ‹€. ${{ secrets.SLACK_WEBHOOK_URL }} 은 slack api μ‚¬μ΄νŠΈμ— 접속 ν›„, App 관리λ₯Ό ν•˜λŠ” λž€μ—μ„œ Incoming Webhook URL을 ν™œμ„±ν™”ν•˜κ²Œ 되면, Webhook URL이 μƒμ„±λ©λ‹ˆλ‹€. 이λ₯Ό GitHub repository의 Setting > Secrets에 λ³€μˆ˜λ‘œ κΈ°μž…ν•©λ‹ˆλ‹€.

Uses: GitHub Actions GitHub Slack

/.github
└── workflows
    └── slack-message.yml

GitHub action을 ν™œμš©ν•˜λ©΄ μƒμ„±λ˜λŠ” 인자(ex. ${{ github.repository }}, ${{ github.author }})듀을 ν™œμš©ν•΄ paylod에 λ„£μ–΄μ£Όμ–΄ μ›ν•˜λŠ” PR κ΄€λ ¨ 정보λ₯Ό 담은 Slack λ©”μ‹œμ§€λ₯Ό 전솑할 수 μžˆλ„λ‘ μ»€μŠ€ν„°λ§ˆμ΄μ§•ν•©λ‹ˆλ‹€.

⚠️ 2번 μ€€λΉ„ 사항

  • Slack Workspace + Channel
  • Slack App (slackapi) with Incoming Webhook ν™œμ„±ν™”

image