장소 검색 결과가 없는 경우에는 위치 정보 없이 재검색하기 (#236) #31
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: | |
- '[0-9]+.[0-9]+.[0-9]+' # Follow semantic versioning | |
- '[0-9]+.[0-9]+.[0-9]+-hotfix[0-9]' # For hotfix | |
workflow_dispatch: # for manual trigger | |
permissions: | |
contents: write | |
id-token: write | |
jobs: | |
backend-ci: | |
runs-on: ubuntu-latest | |
services: | |
postgresql: | |
image: postgres:14.5-alpine | |
ports: | |
- 15432:5432 | |
env: | |
POSTGRES_USER: test | |
POSTGRES_PASSWORD: test | |
POSTGRES_DB: scc_test | |
defaults: | |
run: | |
working-directory: app-server | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set RELEASE_VERSION | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: adopt | |
java-version: 19 | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
# https://github.com/actions/cache/blob/main/examples.md#java---gradle | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Gradle Check | |
run: ./gradlew clean check | |
- uses: actions/upload-artifact@v3 | |
name: Upload Check Report If Failed | |
if: failure() | |
with: | |
name: test report | |
path: "**/build/reports" | |
retention-days: 1 | |
- 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 Docker Image | |
run: ./gradlew jib -Pversion=$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] Backend CI failed. <!subteam^S052B9W7129> (<$CURRENT_GITHUB_ACTION_RUN_URL|github action run url>)\"}" ${{ secrets.SLACK_URL_SCC_SERVER_CHANNEL }} -v | |
# frontend-ci: | |
# runs-on: ubuntu-latest | |
# | |
# defaults: | |
# run: | |
# working-directory: app-admin-frontend | |
# | |
# 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: 18 | |
# | |
# - name: Install & Run openapi-generator | |
# run: | | |
# mkdir -p ~/bin/openapitools | |
# curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh > ~/bin/openapitools/openapi-generator-cli | |
# chmod u+x ~/bin/openapitools/openapi-generator-cli | |
# export PATH=$PATH:~/bin/openapitools/ | |
# | |
# mv ~/bin/openapitools/openapi-generator-cli ~/bin/openapitools/openapi-generator | |
# | |
# OPENAPI_GENERATOR_VERSION=7.1.0 ./generate-api-spec.sh | |
# | |
# - 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 prod $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] Frontend CI failed. <!subteam^S052B9W7129> (<$CURRENT_GITHUB_ACTION_RUN_URL|github action run url>)\"}" ${{ secrets.SLACK_URL_SCC_SERVER_CHANNEL }} -v | |
cd: | |
runs-on: ubuntu-latest | |
needs: | |
- backend-ci | |
# - frontend-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-server | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -i '.image.tag = strenv(RELEASE_VERSION)' 'infra/helm/scc-server/values-prod.yaml' | |
- name: Upgrade scc-server helm chart | |
working-directory: infra/helm/scc-server | |
run: | | |
helm upgrade --install --namespace scc -f values-prod.yaml scc-server ./ | |
# - name: Update image tag for scc-admin-frontend | |
# uses: mikefarah/yq@master | |
# with: | |
# cmd: yq -i '.image.tag = strenv(RELEASE_VERSION)' 'infra/helm/scc-admin-frontend/values-prod.yaml' | |
# | |
# - name: Upgrade scc-admin-frontend helm chart | |
# working-directory: infra/helm/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-server deployment failed. <!subteam^S052B9W7129> (<$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-server version $RELEASE_VERSION is deployed!\"}" ${{ secrets.SLACK_URL_SCC_SERVER_CHANNEL }} -v | |
update-main-branch: | |
runs-on: ubuntu-latest | |
needs: | |
- cd | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set RELEASE_VERSION | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- uses: actions/checkout@v3 | |
with: | |
ref: refs/heads/main | |
token: ${{ secrets.STAIRCRUSHERCLUB_ACCOUNT_GH_TOKEN }} | |
- name: Update image tag for scc-server | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -i '.image.tag = strenv(RELEASE_VERSION)' 'infra/helm/scc-server/values-prod.yaml' | |
# - name: Update image tag for scc-admin-frontend | |
# uses: mikefarah/yq@master | |
# with: | |
# cmd: yq -i '.image.tag = strenv(RELEASE_VERSION)' 'infra/helm/scc-admin-frontend/values-prod.yaml' | |
- name: Commit and push image tag for main branch | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Stair-Crusher-Club" | |
git diff | |
git add . | |
git commit -m "[skip ci] Prod deploy: $RELEASE_VERSION" | |
git push |