Github Action
2022-06-08
๐งถ #git-action #git
Github blog ์ ์์ ์ํด Github Action ์ฌ์ฉํด๋ณด๊ธฐ
repository ์์ฑ
[user id].github.io์ด๋ฆ์ผ๋ก repository ์์ฑ
deploy key ์์ฑ ๋ฐ ๋ฑ๋ก
ssh-keygen -t rsa -f ./[key file name] -C https://github.com/[user id]/[repository name]- file_name.pub ํ์ผ์ ์ ์ฒด ๋ด์ฉ์ ๋ณต์ฌํ์ฌ
- Settings > Deploy keys > [Add deploy key] > Key ์ ๋ถ์ฌ๋ฃ๊ธฐ
- Title์
Public key of ACTIONS_DEPLOY_KEY๋ก ์์ฑ
- Settings > Environments > New environment >
github-pages์์ฑ ํ ํด๋น ํ๊ฒฝ ํด๋ฆญ- ์ดํ Environment secrets์์
[+] Add Secretํด๋ฆญ
- ์ดํ Environment secrets์์
- 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
2022-10-20
2022-06-21