Skip to content

Update gradle.yml

Update gradle.yml #13

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches: [ "main" ]
pull_request:
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'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build --stacktrace
- name: Make directory
run: mkdir -p deploy
- name: Copy War
run: cp ./build/libs/green_parking_11-0.0.1-SNAPSHOT.war ./deploy/parking.war
- name: copy file via ssh password
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASS }}
port: ${{ secrets.PORT }}
source: "deploy/parking.war"
target: ${{ secrets.target_dir }}
overwrite: "true"
- name: File Touch with SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: "ubuntu"
key: ${{ secrets.SECRET_KEY }}
port: 22
debug: true
script: |
systemctl stop tomcat9.service
cp /var/lib/tomcat9/webapps/parking.war /var/lib/tomcat9/back_webapp/parking.war
rm -rf /var/lib/tomcat9/webapps/parking
cp /var/lib/tomcat9/deploy/parking.war /var/lib/tomcat9/webapps/parking.war
rm -rf /var/lib/tomcat9/webapps/deploy
systemctl restart tomcat9.service
systemctl restart apache2