[BE] hotfix ๋ก ์ธํ ์ด์์๋ฒ ๋ณ๊ฒฝ ์ฌํญ ๊ฐ๋ฐ์๋ฒ์ ์ ์ฉ #78
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: Backend develop CI/CD | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: [ develop-BE ] | |
types: [ closed ] | |
paths: backend/** | |
permissions: | |
contents: read | |
jobs: | |
build-and-upload: | |
if: github.event.pull_request.merged | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
token: ${{ secrets.SUBMODULE_ACCESS_TOKEN }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: ํ ์คํธ ํ๊ฒฝ๋ณ์ ์ค์ | |
run: | | |
echo "TEST_JWT_SECRET_KEY=${{ secrets.TEST_JWT_SECRET_KEY }}" >> $GITHUB_ENV | |
echo "TEST_JWT_EXPIRE_LENGTH=${{ secrets.TEST_JWT_EXPIRE_LENGTH }}" >> $GITHUB_ENV | |
- name: gradlew ์คํ ๊ถํ ๋ถ์ฌ | |
run: chmod +x gradlew | |
working-directory: backend | |
- name: Gradle build ์์ | |
run: ./gradlew clean build | |
working-directory: backend | |
- name: Docker buildx ์ค์น | |
uses: docker/[email protected] | |
- name: Docker Hub ๋ก๊ทธ์ธ | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_DEV_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_DEV_TOKEN }} | |
- name: Docker Image Build | |
working-directory: backend | |
run: docker build --platform linux/arm64/v8 -t mapbefine/mapbefine -f Dockerfile-dev . | |
- name: Docker Hub Push | |
run: docker push mapbefine/mapbefine | |
deploy: | |
if: github.event.pull_request.merged | |
runs-on: [ self-hosted, dev ] | |
needs: build-and-upload | |
steps: | |
- name: ์ต์ Docker Image ๊ฐ์ ธ์ค๊ธฐ | |
run: | | |
sudo docker login --username ${{ secrets.DOCKERHUB_DEV_USERNAME }} --password ${{ secrets.DOCKERHUB_DEV_TOKEN }} | |
sudo docker pull mapbefine/mapbefine:latest | |
- name: Docker Compose | |
run: | | |
cd /home/ubuntu/backend | |
sudo sh zero-downtime-deploy.sh | |
sudo docker image prune -af | |
- name: ์ฌ๋ ๋ฉ์์ง ๋ณด๋ด๊ธฐ | |
uses: 8398a7/action-slack@v3 | |
with: | |
mention: 'here' | |
if_mention: always | |
status: ${{ job.status }} | |
fields: workflow,job,commit,message,ref,author,took | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
if: always() |