Skip to content

Merge pull request #7 from famo1245/feat/group #3

Merge pull request #7 from famo1245/feat/group

Merge pull request #7 from famo1245/feat/group #3

Workflow file for this run

name: "santa deploy EC2"
on:
push:
branches-ignore:
- main
paths:
- 'backend/**'
jobs:
deploy:
if: github.repository == 'famo1245/santa'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v3
- name: Create database-stage.properties
run: |
echo '${{ secrets.DATABASE_STAGE_PROPERTIES }}' > ./src/main/resources/database-stage.properties
- name: Create oauth.properties
run: |
echo '${{ secrets.OAUTH_PROPERTIES }}' > ./src/main/resources/oauth.properties
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'liberica'
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew clean build -x test
- name: Deploy to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
source: "backend/build/libs/santa-0.0.1-SNAPSHOT.jar"
target: "/home/ubuntu/santa"
strip_components: 3
- name: Execute deploy script
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
export SPRING_ENV=stage
cd santa/
./deploy.sh