Github Action

2022-06-08
๐Ÿ“‚ tool > git
๐Ÿงถ #git-action #git

Github blog ์ œ์ž‘์„ ์œ„ํ•ด Github Action ์‚ฌ์šฉํ•ด๋ณด๊ธฐ

repository ์ƒ์„ฑ

  • [user id].github.io ์ด๋ฆ„์œผ๋กœ repository ์ƒ์„ฑ

deploy key ์ƒ์„ฑ ๋ฐ ๋“ฑ๋ก

  1. ssh-keygen -t rsa -f ./[key file name] -C https://github.com/[user id]/[repository name]
  2. file_name.pub ํŒŒ์ผ์˜ ์ „์ฒด ๋‚ด์šฉ์„ ๋ณต์‚ฌํ•˜์—ฌ
    • Settings > Deploy keys > [Add deploy key] > Key ์— ๋ถ™์—ฌ๋„ฃ๊ธฐ
    • Title์€ Public key of ACTIONS_DEPLOY_KEY ๋กœ ์ž‘์„ฑ
  3. Settings > Environments > New environment > github-pages ์ƒ์„ฑ ํ›„ ํ•ด๋‹น ํ™˜๊ฒฝ ํด๋ฆญ
    • ์ดํ›„ Environment secrets์—์„œ [+] Add Secret ํด๋ฆญ
  4. file_name ํŒŒ์ผ์˜ ์ „์ฒด ๋‚ด์šฉ์„ ๋ณต์‚ฌํ•˜์—ฌ
    • 3์˜ Value ์— ๋ถ™์—ฌ๋„ฃ๊ธฐ
    • 3์˜ Name์€ ACTIONS_DEPLOY_KEY ๋กœ ์ž‘์„ฑ

github action ์‹คํ–‰ํŒŒ์ผ ์ž‘์„ฑ

  • deploy.yml ํŒŒ์ผ ์ž‘์„ฑํ•˜์—ฌ .github/workflows ํ•˜์œ„์— ์ €์žฅ
1name: GitHub Pages
2
3on:
4  push:
5    branches:
6      - main
7  workflow_dispatch:
8
9jobs:
10  deploy:
11    runs-on: ubuntu-20.04
12    concurrency:
13      group: ${{ github.workflow }}-${{ github.ref }}
14    steps:
15      - uses: actions/checkout@v3
16
17      - name: Setup Node
18        uses: actions/setup-node@v3
19        with:
20          node-version: '14' #local์—์„œ ์‚ฌ์šฉํ•œ ๋ฒ„์ „๊ณผ ๋™์ผํ•˜๊ฒŒ ์ž‘์„ฑ
21
22      - name: Get yarn cache
23        id: yarn-cache
24        run: echo "::set-output name=dir::$(yarn cache dir)"
25
26      - name: Cache dependencies
27        uses: actions/cache@v2
28        with:
29          path: ${{ steps.yarn-cache.outputs.dir }}
30          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
31          restore-keys: |
32            ${{ runner.os }}-yarn-
33      - run: yarn install --frozen-lockfile
34      - run: yarn stack
35      - run: yarn build
36      - run: yarn export # out์— ์žˆ๋Š” ํŒŒ์ผ ๋‚ด์šฉ์ด export๋จ
37
38      - name: Deploy
39        uses: peaceiris/actions-gh-pages@v3
40        if: ${{ github.ref == 'refs/heads/main' }}
41        with:
42          github_token: ${{ secrets.GITHUB_TOKEN }}
43          publish_dir: ./out

๐ŸŽˆ ๊ธฐํƒ€ ๋‚ด์šฉ์€ ์ถ”ํ›„ ๋‹ค๋ฅธ ํฌ์ŠคํŠธ์—์„œ ์„ค๋ช….
์ด ํฌ์ŠคํŠธ์—์„œ๋Š” git action์— ๋Œ€ํ•ด์„œ๋งŒ ์ •๋ฆฌ

git push ํ›„ ํ™•์ธ

/end of Github Action
CONTENT LISTMERRI๏ผ‡s DEVELOG
Ubuntu ๋ช…๋ น์–ด ์ •๋ฆฌ
2022-10-20