Skip to content

๐Ÿ”จ Refactor/#190 - ํ…Œ์ŠคํŠธ์šฉ ์ด๋ฒคํŠธ ์Šค์ผ€์ค„๋ง ์ฃผ๊ธฐ 1๋ถ„์œผ๋กœ ๋‹จ์ถ• #177

๐Ÿ”จ Refactor/#190 - ํ…Œ์ŠคํŠธ์šฉ ์ด๋ฒคํŠธ ์Šค์ผ€์ค„๋ง ์ฃผ๊ธฐ 1๋ถ„์œผ๋กœ ๋‹จ์ถ•

๐Ÿ”จ Refactor/#190 - ํ…Œ์ŠคํŠธ์šฉ ์ด๋ฒคํŠธ ์Šค์ผ€์ค„๋ง ์ฃผ๊ธฐ 1๋ถ„์œผ๋กœ ๋‹จ์ถ• #177

Workflow file for this run

name: Web Application Develop Server CI/CD
on:
pull_request:
branches: [ "dev" ]
types:
- opened
- synchronize
- closed
jobs:
CI:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
# Cache Gradle~
- name: Cache 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-
### runner application java ์„ค์ •
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
### application.yml ์„ค์ •
- name: Set YML
run: |
echo "${{ secrets.APPLICATION_DEV_YML }}" | base64 --decode > ./src/main/resources/application-dev.yml
### firebase-key.json ์„ค์ •
- name: Set Firebase Key
run: |
mkdir -p ./src/main/resources/firebase
echo "${{ secrets.FIREBASE_KEY_JSON }}" | base64 --decode > ./src/main/resources/firebase/firebase-key.json
### gradlew ์‹คํ–‰ ๊ถŒํ•œ ๋ถ€์—ฌ
- name: Grant execute Permission for gradlew
run: |
chmod +x gradlew
### project build
- name: Build with Gradle
run: |
./gradlew clean build -x test
### Docker Image Build and Push
- name: Login to Docker Hub
if: github.event.pull_request.merged == true
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up Docker Buildx
if: github.event.pull_request.merged == true
uses: docker/setup-buildx-action@v2
- name: Build and push
if: github.event.pull_request.merged == true
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}
# closed์— ๋Œ€ํ•œ server deploy
CD:
if: github.event.pull_request.merged == true
needs: [CI]
runs-on: ubuntu-20.04
steps:
### SSH Connect and Docker Image Pull and Container Run
- name: Docker Image Pull and Container Run
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEV_SSH_HOST }}
username: ${{ secrets.DEV_SSH_USERNAME }}
key: ${{ secrets.DEV_SSH_KEY }}
port: ${{ secrets.DEV_SSH_PORT }}
script: |
docker stop api-server
docker rm api-server
docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}
docker run -d -p 8080:8080 --name api-server --network ${{secrets.DOCKER_NETWORKNAME}} ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}