diff --git a/.github/workflows/android.yaml b/.github/workflows/android.yaml index 4fccdfb8..316c79e6 100644 --- a/.github/workflows/android.yaml +++ b/.github/workflows/android.yaml @@ -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 \ No newline at end of file + run: ./gradlew clean build \ No newline at end of file diff --git a/.github/workflows/springboot.yaml b/.github/workflows/springboot-on-pr.yaml similarity index 87% rename from .github/workflows/springboot.yaml rename to .github/workflows/springboot-on-pr.yaml index 0abd3527..253bd0ad 100644 --- a/.github/workflows/springboot.yaml +++ b/.github/workflows/springboot-on-pr.yaml @@ -1,8 +1,6 @@ -name: Springboot CI +name: Springboot CI on PR on: - push: - branches: [ "develop", "main" ] pull_request: branches: [ "develop", "main" ] @@ -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 diff --git a/.github/workflows/springboot-on-push.yaml b/.github/workflows/springboot-on-push.yaml new file mode 100644 index 00000000..6ba858b3 --- /dev/null +++ b/.github/workflows/springboot-on-push.yaml @@ -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/ssh-agent@v0.5.4 + 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 &" diff --git a/android/.idea/deploymentTargetDropDown.xml b/android/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 7e0dc85b..00000000 --- a/android/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/springboot/build.gradle.kts b/springboot/build.gradle.kts index 6c174f69..02f51331 100644 --- a/springboot/build.gradle.kts +++ b/springboot/build.gradle.kts @@ -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()