Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/deploy springboot CD #63

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@ jobs:
- name: Add API_BASE_URL to local.properties
run: echo "API_BASE_URL= \"${{ secrets.API_BASE_URL }}\"" >> local.properties
- name: Build with Gradle
run: ./gradlew clean build
- name: Test with Gradle
run: ./gradlew test
run: ./gradlew clean build
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Springboot CI
name: Springboot CI on PR

on:
push:
branches: [ "develop", "main" ]
pull_request:
branches: [ "develop", "main" ]

Expand Down Expand Up @@ -30,9 +28,8 @@ jobs:
src/test/kotlin/com/goliath/emojihub/springboot/TestServiceAccountKey.json
ls -al src/test/kotlin/com/goliath/emojihub/springboot/

# Build & Test
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build
- name: Test with Gradle
run: ./gradlew test
65 changes: 65 additions & 0 deletions .github/workflows/springboot-on-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Springboot CI/CD on Push

on:
push:
branches: [ "develop" ]
# for debug
pull_request:
branches: [ "develop" ]

jobs:
build:

runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./springboot

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Add test account key from secrets
run: |
echo "${{ secrets.FIREBASE_TEST_ACCOUNT_KEY }}" | base64 -d > \
src/test/kotlin/com/goliath/emojihub/springboot/TestServiceAccountKey.json
ls -al src/test/kotlin/com/goliath/emojihub/springboot/

# Build & Test
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build

# Setup SSH
- name: Set up SSH agent with private key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SPRINGBOOT_EC2_SSH_KEY }}
- name: Add remote server to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.SPRINGBOOT_HOST_DNS }} >> ~/.ssh/known_hosts

# Deploy
- name: SCP jar file to server
run: |
scp *jar ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }}:\
${{ secrets.SPRINGBOOT_TARGET_DIR }}
working-directory: ./springboot/build/libs
- name: Execute remote commands
run: |
ssh -v ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }} \
"echo hello"
ssh -v ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }} \
"sudo kill -9 \$(pgrep -f springboot-0.0.1-SNAPSHOT.jar) || true"
ssh -v ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }} \
"cd ${{ secrets.SPRINGBOOT_ROOT_DIR }} && pwd && \
sudo nohup /usr/bin/java -jar ${{ secrets.SPRINGBOOT_TARGET_DIR }}/*.jar \
> ${{ secrets.SPRINGBOOT_ROOT_DIR }}/app.log 2>&1 &"
17 changes: 0 additions & 17 deletions android/.idea/deploymentTargetDropDown.xml

This file was deleted.

6 changes: 3 additions & 3 deletions springboot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ group = "com.goliath.emojihub"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17

//java {
// sourceCompatibility = JavaVersion.VERSION_17
//}
tasks.getByName("jar") {
enabled = false
}

repositories {
mavenCentral()
Expand Down
Loading