๐จ Refactor/#185 - ๊ฒ์ํ์ ๊ธฐ๊ฐ ์ถ๊ฐ, ๊ธฐ๊ฐ์ ๋ฐ๋ฅธ ์ค์ผ์ค๋ง ๋ก์ง ์ถ๊ฐ ๋ฐ Response ๋ณ๊ฒฝ #174
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: 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 }} |