Skip to content

🚑 HotFix - User Mapped with Medication, Question #47

🚑 HotFix - User Mapped with Medication, Question

🚑 HotFix - User Mapped with Medication, Question #47

Workflow file for this run

name: API Server CI/CD
on:
pull_request:
path: "server-api/**"
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_YML }}" | base64 --decode > ./server-api/src/main/resources/application-dev.yml
### Firebase Key 설정
- name: Set Firebase Key
run: |
mkdir -p ./server-api/src/main/resources/firebase
echo "${{ secrets.FIREBASE_ADMIN_KEY }}" | base64 --decode > ./server-api/src/main/resources/firebase/firebase-admin-key.json
### gradlew 실행 권한 부여
- name: Grant execute Permission for gradlew
run: |
cd ./server-api
chmod +x ./gradlew
### project build
- name: Build with Gradle
run: |
cd ./server-api
./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_TOKEN }}
- 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: ./server-api/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.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: |
docker stop wooahan-was
docker rm wooahan-was
docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}
docker run -d --name wooahan-was -e TZ=Asia/Seoul -p 8080:8080 --net wooahan --ip 172.20.0.5 ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}