๐ refactor: ์๋ฆผ ๊ด๋ จ api ๊ตฌํ (#375) #180
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: CD | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "develop" ] | |
paths-ignore: | |
- '**/*.md' | |
permissions: | |
contents: read | |
env: | |
DOCKER_REPOSITORY: sponus | |
APPLICATION_SECRET_PATH: ./api/src/main/resources | |
jobs: | |
deploy-with-docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# Gradle caching | |
- name: Gradle Caching | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# Create application-secret.yaml | |
- name: Make application-secret.yml | |
run: | | |
mkdir -p $APPLICATION_SECRET_PATH | |
touch $APPLICATION_SECRET_PATH/application-secret.yml | |
echo "${{ secrets.APPLICATION_SECRET }}" > $APPLICATION_SECRET_PATH/application-secret.yml | |
## firebase-key ์ค์ | |
- name: Set FCM | |
env: | |
DATA: ${{ secrets.FIREBASE_KEY }} | |
run: | | |
mkdir -p ./core/core-infra-firebase/src/main/resources/firebase | |
echo $DATA > ./core/core-infra-firebase/src/main/resources/firebase/firebase-key.json | |
# Grant execute permission for gradlew | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
# Build with Gradle | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
# Docker Hub ๋ก๊ทธ์ธ | |
- name: Docker Hub ๋ก๊ทธ์ธ | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# Docker build & Push | |
- name: Docker build & Push | |
run: | | |
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_REPOSITORY }} . | |
docker push ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_REPOSITORY }} | |
# Send deploy.sh & docker-compose.yaml | |
- name: Send deploy.sh | |
uses: appleboy/scp-action@master | |
with: | |
username: ubuntu | |
host: ${{ secrets.EC2_HOST }} | |
key: ${{ secrets.EC2_PRIVATE_KEY }} | |
port: 22 | |
source: "./deploy/*" | |
target: "~" | |
# Deploy to Dev | |
- name: Deploy to Dev | |
uses: appleboy/ssh-action@master | |
with: | |
username: ubuntu | |
host: ${{ secrets.EC2_HOST }} | |
key: ${{ secrets.EC2_PRIVATE_KEY }} | |
script: | | |
cd deploy | |
chmod 777 ./deploy.sh | |
./deploy.sh | |
docker image prune -f |