π BugFix/#194 - λκΈ μμ±μκ° κΈ μμ±μλ‘ νμλλ λ²κ·Έ μμ #194 #181
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 }} |