feat: github workflow main.yml 구현 #1
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: Deploy to release Server | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
name: Build and Push to Oracle Cloud | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '17' | ||
- name: set credentials in application.yaml | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: './src/main/resources/application.yaml' | ||
env: | ||
spring.profiles.active: release | ||
- name: set credentials in application-release.yaml | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: './src/main/resources/application-release.yaml' | ||
env: | ||
spring.datasource.url: ${{ secrets.MYSQL_DATASOURCE_URL }} | ||
spring.datasource.username: ${{ secrets.MYSQL_DATASOURCE_USERNAME }} | ||
spring.datasource.password: ${{ secrets.MYSQL_DATASOURCE_PASSWORD }} | ||
spring.data.redis.host: ${{ secrets.REDIS_DATASOURCE_HOST }} | ||
spring.data.redis.port: ${{ secrets.REDIS_DATASOURCE_PORT }} | ||
cookie.encode: ${{ SECRET_KEY }} | ||
Check failure on line 42 in .github/workflows/main.yml GitHub Actions / Deploy to release ServerInvalid workflow file
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
- name: Build with Gradle | ||
run: ./gradlew build | ||
- name: Deploy via SCP | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.ORACLE_SERVER_HOST }} | ||
username: ${{ secrets.ORACLE_SERVER_USERNAME }} | ||
key: ${{ secrets.ORACLE_SERVER_SSH_KEY }} | ||
port: $ {{ secrets.ORACLE_SERVER_PORT }} | ||
target: ${{ secrets.DEPLOY_TARGET }} | ||
rm: true | ||
- name: Deploy to Server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.ORACLE_SERVER_HOST }} | ||
username: ${{ secrets.ORACLE_SERVER_USERNAME }} | ||
key: ${{ secrets.ORACLE_SERVER_SSH_KEY }} | ||
port: $ {{ secrets.ORACLE_SERVER_PORT }} | ||
script: | | ||
cd /home/ubuntu/project/areyouhere-server | ||
nohup sudo java -jar are-you-here.jar > output.log & | ||
sudo lsof -ti:8080 | sudo xargs kill -9 || true |