Update README.md #50
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: Java CI/CD with Gradle | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Grant execute permission for Gradle | |
run: chmod +x ./gradlew | |
- name: Create application.properties | |
run: | | |
mkdir -p src/main/resources | |
echo "${{ secrets.APPLICATION_PROPERTIES }}" > src/main/resources/application.properties | |
- name: Set Email From Address | |
run: echo "EMAIL_FROM_ADDRESS=${{ secrets.EMAIL_FROM_ADDRESS }}" >> $GITHUB_ENV | |
- name: Build with Gradle Wrapper | |
run: ./gradlew bootjar | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifact | |
path: build/libs/*.jar | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-artifact | |
- name: Setup SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_KEY }} | |
- name: Add server to known_hosts | |
run: | | |
ssh-keyscan -p ${{ secrets.PORT }} ${{ secrets.SERVER_IP_ADDRESS }} >> ~/.ssh/known_hosts | |
- name: SCP Transfer | |
run: scp -P ${{ secrets.PORT }} /home/runner/work/LSA_Server_SpringBoot/LSA_Server_SpringBoot/LSA-0.0.1-SNAPSHOT.jar ${{ secrets.USER }}@${{ secrets.SERVER_IP_ADDRESS }}:/home/ubuntu/LSA_release | |
- name: Restart server | |
run: | | |
ssh -p ${{ secrets.PORT }} ${{ secrets.USER }}@${{ secrets.SERVER_IP_ADDRESS }} 'sudo systemctl restart LSAServer.service' |