๐จ [HOTFIX] QA ๋์ค ๋ฌธ์ ์๊ธฐ๋ ๋ถ๋ถ ๋ก๊ทธ ์ฐ์ด๋ณด๊ธฐ #61
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: CI/CD using github actions & docker | |
on: | |
push: | |
branches: [ "dev" ] | |
permissions: | |
contents: read | |
jobs: | |
CI-CD: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. ๋ฆฌํฌ์งํ ๋ฆฌ ์ฝ๋ ์ฒดํฌ์์ | |
- uses: actions/checkout@v3 | |
# 2. JDK 17 ์ธํ (๋น๋๋ฅผ ์ํด) | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# 3. Gradle Caching | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# 4. application.yml ํ์ผ ์์ฑ | |
- name: make application.yml | |
run: | | |
mkdir -p ./src/main/resources | |
cd ./src/main/resources | |
touch application.yml | |
echo "${{ secrets.YML }}" > application.yml | |
shell: bash | |
# 5. Gradle ๋น๋ (ํ ์คํธ ์ ์ธ) | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
# 6. Set up Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# 7. Set up QEMU for multi-platform | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: all | |
# 8. Docker ๋ก๊ทธ์ธ | |
- name: Docker Login | |
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
# 9. Docker ์ด๋ฏธ์ง ๋น๋ & ํธ์ (multi-platform) | |
- name: Docker build & push | |
run: | | |
docker buildx build \ | |
--platform linux/amd64 \ | |
--push \ | |
-t ${{ secrets.DOCKER_USERNAME }}/with-suhyeon . | |
# 10. ์๊ฒฉ ์๋ฒ ๋ฐฐํฌ | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST_PROD }} | |
username: root | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
cd /root/with-suhyeon # docker-compose.yml ํ์ผ์ด ์๋ ํด๋ | |
# 1) ํน์ ์คํ์ค์ธ ์ปจํ ์ด๋ ์์ผ๋ฉด ์ข ๋ฃ | |
docker-compose down | |
# 2) ์ต์ ์ด๋ฏธ์ง pull | |
docker-compose pull | |
# 3) ๋ฐฑ๊ทธ๋ผ์ด๋ ์คํ | |
docker-compose up -d --remove-orphans | |
# 4) ํ์ ์ ์ฌ์ฉ ์ ํ๋ ์ด๋ฏธ์ง ์ ๋ฆฌ | |
docker image prune -f |