개밥먹기 과정에서 발견한 자잘한 오류 수정 & 개선사항 적용 (#6) #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: prod-ci-cd | |
on: | |
push: | |
tags: | |
- "v?[0-9]+.[0-9]+.[0-9]+" | |
- "v?[0-9]+.[0-9]+.[0-9]+-[a-z]+.?[0-9]?" # ex. 0.0.0-hotfix.1 // pre-release, filter pattern의 한계로 "-hotfix.10" 은 매칭되지 않음 | |
- 'v?[0-9]+.[0-9]+.[0-9]+\+[a-z0-9]+' # ex. 0.0.0+3f4f3f4 // build number | |
- 'v?[0-9]+.[0-9]+.[0-9]+-[a-z]+.?[0-9]?\+[a-z0-9]+' # ex. 0.0.0-hotfix.1+3f4f3f4 // pre-release with build number | |
workflow_dispatch: # for manual trigger | |
permissions: | |
contents: write | |
id-token: write | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set RELEASE_VERSION | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::291889421067:role/github-action-ci-cd | |
aws-region: ap-northeast-2 | |
- name: Build and Push Image | |
run: ./docker-push.sh live $RELEASE_VERSION | |
- name: Notify CD failure to slack | |
if: failure() | |
run: | | |
CURRENT_GITHUB_ACTION_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"[PROD] Admin Frontend CI failed. (<$CURRENT_GITHUB_ACTION_RUN_URL|github action run url>)\"}" ${{ secrets.SLACK_URL_SCC_SERVER_CHANNEL }} -v | |
cd: | |
runs-on: ubuntu-latest | |
needs: | |
- ci | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set RELEASE_VERSION | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Install kubeconfig | |
env: | |
SCC_K3S_KUBECONFIG: ${{ secrets.SCC_K3S_KUBECONFIG }} | |
run: | | |
mkdir -p ~/.kube && echo "$SCC_K3S_KUBECONFIG" > ~/.kube/config | |
- uses: azure/setup-helm@v1 | |
with: | |
version: "3.8.2" | |
id: install-helm | |
- uses: azure/setup-kubectl@v3 | |
with: | |
version: "v1.24.1" | |
id: install-kubectl | |
- name: Update image tag for scc-admin-frontend | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -i '.image.tag = strenv(RELEASE_VERSION)' 'helm-chart/scc-admin-frontend/values-prod.yaml' | |
- name: Upgrade scc-admin-frontend helm chart | |
working-directory: helm-chart/scc-admin-frontend | |
run: | | |
helm upgrade --install --namespace scc -f values-prod.yaml scc-admin-frontend ./ | |
- name: Notify CD failure to slack | |
if: failure() | |
run: | | |
CURRENT_GITHUB_ACTION_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"[PROD] scc-admin-frontend deployment failed. (<$CURRENT_GITHUB_ACTION_RUN_URL|github action run url>)\"}" ${{ secrets.SLACK_URL_SCC_SERVER_CHANNEL }} -v | |
- name: Set RELEASE_VERSION | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Notify CD success to slack | |
if: success() | |
run: | | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" | |
CURRENT_GITHUB_ACTION_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"[PROD] scc-admin-frontend version $RELEASE_VERSION is deployed!\"}" ${{ secrets.SLACK_URL_SCC_SERVER_CHANNEL }} -v |