-
Notifications
You must be signed in to change notification settings - Fork 3
[INITOS-JIWON] - Github Actions & Discord #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # Github Actions 도입하기 | ||
|
|
||
| ## 1. Self hosted runner 등록하기 | ||
|
|
||
| os 이미지 빌드의 무거움을 해소하기 위해 self hosted runner 사용 | ||
|
|
||
| ```bash | ||
| # Create a folder | ||
| $ mkdir actions-runner && cd actions-runnerCopied!# Download the latest runner package | ||
| $ curl -o actions-runner-linux-x64-2.325.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.325.0/actions-runner-linux-x64-2.325.0.tar.gzCopied!# Optional: Validate the hash | ||
| $ echo "5020da7139d85c776059f351e0de8fdec753affc9c558e892472d43ebeb518f4 actions-runner-linux-x64-2.325.0.tar.gz" | shasum -a 256 -cCopied!# Extract the installer | ||
| $ tar xzf ./actions-runner-linux-x64-2.325.0.tar.gz | ||
|
|
||
| # Create the runner and start the configuration experience | ||
| $ ./config.sh --url https://github.com/yucori/bootc-practice --token {MY_TOKEN}# Last step, run it! | ||
| $ ./run.sh | ||
|
|
||
| # Use this YAML in your workflow file for each job | ||
| runs-on: self-hosted | ||
| ``` | ||
|
|
||
| - runner 등록 과정에서 Must not run with sudo 문제 발생 | ||
| ⇒ `export RUNNER_ALLOW_RUNASROOT="1"` 으로 문제 해결 | ||
| - 원래 runner는 root 사용이 비권장되지만, bootc를 통해 os 이미지를 관리하기 위해서 root로 runner 실행하도록 함 | ||
|
Comment on lines
+22
to
+24
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| ## 2. workflow 작성 | ||
|
|
||
| ```yaml | ||
| name : Build & Push | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: self-hosted | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install Podman | ||
| run: sudo apt install -y podman | ||
|
|
||
| - name: Build an image | ||
| run: podman build -t bootc:latest /root | ||
|
|
||
| - name: Login Registry | ||
| run: podman login -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_PW }} docker.io | ||
|
|
||
| - name: Push an Image | ||
| run: podman push bootc:latest docker.io/${{ secrets.REGISTRY_USER }}/bootc:latest | ||
|
|
||
| ``` | ||
|
|
||
| - workflow 작성 후 secrets 변수들 등록 | ||
| - runner를 run.sh로 단순 실행했다가 터미널이 종료되면 runner가 listen을 못하기에 nohup을 통해 백그라운드로 실행 | ||
| - `nohup ./run.sh & > nohup.out` | ||
|
Comment on lines
+56
to
+57
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 홈서버 스터디 때 말한건데...😂 |
||
|
|
||
|  | ||
|
|
||
| 빌드 후 도커 허브에 업로드까지 완료! | ||
|
|
||
| 이 김에 push 시에 디코로 알림이 오도록 설정 | ||
|
|
||
| 디코에 채널 만들고 webhook 링크를 깃헙에 등록 | ||
|
|
||
| ```yaml | ||
| name : Build & Push | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| notify_discord: | ||
| runs-on: self-hosted | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Notify Discord | ||
| uses: rjstone/discord-webhook-notify@v1 | ||
| with: | ||
| severity: info | ||
| details: "${{ github.actor }} added new push\n📜 ${{ github.event.head_commit.message }}" | ||
| webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | ||
|
|
||
| build: | ||
| runs-on: self-hosted | ||
| needs: notify_discord | ||
|
|
||
| steps: | ||
| - name: Install Podman | ||
| run: sudo apt install -y podman | ||
|
|
||
| - id: build-phase | ||
| name: Build an image | ||
| run: podman build -t bootc:latest /root | ||
|
|
||
| - name: Login Registry | ||
| run: podman login -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_PW }} docker.io | ||
|
|
||
| - name: Push an Image | ||
| run: podman push bootc:latest docker.io/${{ secrets.REGISTRY_USER }}/bootc:latest | ||
|
|
||
| - name: 'Notify Discord - Success' | ||
| if: steps.build-phase.outcome == 'success' | ||
| uses: rjstone/discord-webhook-notify@v1 | ||
| with: | ||
| severity: info | ||
| details: 'Build - Success' | ||
| webhookUrl: ${{secrets.DISCORD_WEBHOOK }} | ||
|
|
||
| - name: 'Notify Discord - Fail' | ||
| if: steps.build-phase.outcome != 'success' | ||
| uses: rjstone/discord-webhook-notify@v1 | ||
| with: | ||
| severity: error | ||
| details: 'Build - Fail' | ||
| webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | ||
|
Comment on lines
+116
to
+122
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. star 75개 Community action이라 유의해서 사용 (직접 만드는 거 권장) |
||
|
|
||
| ``` | ||
|
|
||
|  | ||
|
|
||
| 성공~ 굳굳티비~ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
secrets 말고도 vars도 있으니 다음에 사용할 땐 참고