Update ci_and_cd.yml #42
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: CI & CD with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- uses: mirromutth/[email protected] | |
with: | |
host port: 3306 | |
container port: 3306 | |
mysql database: 'appcenter' | |
mysql user: 'root' | |
mysql password: ${{ secrets.MYSQL_PWD }} | |
- name: Download application YML | |
run: | | |
mkdir -p src/main/resources | |
echo "${{ secrets.APPLICATION_YML }}" | base64 --decode > src/main/resources/application.yml | |
find src | |
- name: Download SQL | |
run: | | |
mkdir -p src/main/resources | |
echo "${{ secrets.DATA_SQL }}" | base64 --decode > src/main/resources/data.sql | |
find src | |
- name: Gradle build | |
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 | |
with: | |
arguments: build -x test | |
- name: Upload Jacoco report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: index | |
path: build/jacocoHTML | |
- name: SCP files to server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USER }} | |
password: ${{ secrets.SERVER_PWD }} | |
port: 22 | |
source: "./build/libs/*.jar" | |
target: /home/serverking/appcenter-homepage | |
- name: Execute script via SSH | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USER }} | |
password: ${{ secrets.SERVER_PWD }} | |
port: 22 | |
script_stop: true | |
script: | | |
cd /home/serverking/appcenter-homepage | |
sh deploy.sh |