Skip to content

snake_case로 변경 #101

snake_case로 변경

snake_case로 변경 #101

Workflow file for this run

name: Build and Deploy API - test
on:
push:
branches:
- test
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_TEST }}" > ./.env
- name: Generate logback.xml for API
run: |
cd ./api/src/main/resources
cat <<EOF > logback.xml
${{ secrets.LOGBACK_API_TEST }}
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_TEST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY_TEST }}
port: 22
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