-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Backend Build with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "backend-main" ] | ||
pull_request: | ||
branches: [ "main", "backend-main" ] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache Gradle dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('backend/**/*.gradle*', 'backend/**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Create Config | ||
run: | | ||
mkdir -p src/main/resources | ||
mkdir -p src/test/resources | ||
echo "${{ secrets.MAIN_APPLICATION_YML }}" > src/main/resources/application.yml | ||
echo "${{ secrets.MAIN_APPLICATION_DEV_YML }}" > src/main/resources/application-dev.yml | ||
echo "${{ secrets.MAIN_APPLICATION_PROD_YML }}" > src/main/resources/application-prod.yml | ||
echo "${{ secrets.TEST_APPLICATION_YML }}" > src/test/resources/application.yml | ||
echo "${{ secrets.TEST_APPLICATION_TEST_YML }}" > src/test/resources/application-test.yml | ||
working-directory: backend | ||
|
||
- name: Grant execute permission for Gradle | ||
run: chmod +x gradlew | ||
working-directory: backend | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build | ||
working-directory: backend | ||
|
||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: Add SSH key to known hosts | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan ${{ secrets.BE_SERVER_IP }} >> ~/.ssh/known_hosts | ||
|
||
- name: SCP transfer | ||
run: scp backend/build/libs/*.jar ${{ secrets.SSH_USER }}@${{ secrets.BE_SERVER_IP }}:~/deploy |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Deploy Backend Application | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: Add SSH key to known hosts | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan ${{ secrets.BE_SERVER_IP }} >> ~/.ssh/known_hosts | ||
- name: Deploy Backend application | ||
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.BE_SERVER_IP }} "bash /home/ubuntu/deploy/deploy.sh" |