Skip to content

fix: review 삭제 수정 #54

fix: review 삭제 수정

fix: review 삭제 수정 #54

Workflow file for this run

name: Build and Deploy
on:
push:
branches: [ "main", "develop" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
distribution: 'adopt'
java-version: '17'
- name: Set up Apple Key File
run: |
mkdir src/main/resources/key
echo "${{ secrets.APPLE_KEY }}" > src/main/resources/key/key.p8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get current time
run: echo "CURRENT_TIME=$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV
- name: Build and Push Docker image - prod
if: github.ref == 'refs/heads/main'
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.CURRENT_TIME }},
${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
platforms: linux/amd64
- name: Build and Push Docker image - dev
if: github.ref == 'refs/heads/develop'
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DEV_DOCKER_IMAGE_NAME }}:${{ env.CURRENT_TIME }},
${{ secrets.DOCKER_USERNAME }}/${{ secrets.DEV_DOCKER_IMAGE_NAME }}:latest
platforms: linux/arm64
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: SSH to Server and Deploy - prod
if: github.ref == 'refs/heads/main'
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
port: ${{ secrets.SERVER_PORT }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_KEY }}
script: |
cd ~/Dongpo
aws secretsmanager get-secret-value --secret-id ${{ secrets.AWS_SECRET_NAME }} --query 'SecretString' --output text | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' > .env
docker-compose pull
docker-compose up -d
docker image prune -f
- name: SSH to Server and Deploy - dev
if: github.ref == 'refs/heads/develop'
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEV_SERVER_HOST }}
port: ${{ secrets.DEV_SERVER_PORT }}
username: ${{ secrets.DEV_SERVER_USERNAME }}
password: ${{ secrets.DEV_SERVER_PASSWORD }}
script: |
cd ~/Dongpo_dev
aws secretsmanager get-secret-value --secret-id ${{ secrets.DEV_AWS_SECRET_NAME }} --query 'SecretString' --output text | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' > .env
./deploy.sh