Skip to content

Merge pull request #420 from Kernel360/feat-admin-setting #12

Merge pull request #420 from Kernel360/feat-admin-setting

Merge pull request #420 from Kernel360/feat-admin-setting #12

Workflow file for this run

name: Build and Deploy API - release
on:
push:
branches:
- release
paths:
- 'api/**'
- 'domain/**'
- 'infrastructure/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set environment values for API
run: |
cd ./api/src/main/resources
touch ./.env
echo "${{ secrets.ENV }}" > ./.env
- name: Generate logback.xml for API
run: |
cd ./api/src/main/resources
cat <<EOF > logback.xml
${{ secrets.LOGBACK_API }}
EOF
- name: Set Gradle Wrapper Permissions
run: chmod +x ./gradlew
- name: Build API
run: ./gradlew :api:assemble
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Build and push Docker image for API
run: |
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker-compose build badminton-api
docker-compose push badminton-api
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy API on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PUBLIC_DNS }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo "Docker Hub에 로그인"
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | sudo docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
echo "badminton-api 서비스 업데이트"
sudo docker-compose pull badminton-api
sudo docker-compose up -d badminton-api
echo "오래된 Docker 이미지 정리"
sudo docker image prune -f