chore: github action 작동 상태 #3
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: Prod - CI/CD with Tests | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./ | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Clean Build with Gradle (with Tests) | |
run: | | |
echo ${{ secrets.APPLICATION_PROD_YML }} | base64 --decode > ./src/main/resources/application-prod.yml | |
./gradlew clean build | |
- name: Deploy to EC2 | |
env: | |
PRIVATE_KEY: ${{ secrets.YOURSSU_SECRET }} | |
HOST: ${{ secrets.YOURSSU_PROD_HOST }} | |
run: | | |
mkdir -p ~/.ssh | |
ssh-keyscan -H $HOST >> ~/.ssh/known_hosts | |
echo "$PRIVATE_KEY" > private_key.pem | |
chmod 600 private_key.pem | |
mv build/libs/soongpt-0.0.1-SNAPSHOT.jar yourssu-soongpt-application.jar | |
scp -i private_key.pem yourssu-soongpt-application.jar ubuntu@$HOST:/home/ubuntu/soongpt-api | |
ssh -i private_key.pem ubuntu@$HOST "/home/ubuntu/soongpt-api/run.sh" |