change dir first #5
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: GitHub BabysBaby | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the main branch on GitHub | |
uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
cache: 'maven' | |
- name: Build Maven Project | |
run: | | |
cd Baby | |
mvn -B package --file pom.xml | |
mkdir staging && cp target/*.jar staging | |
- name: Move old BabysBaby.jar to a save place | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: mkdir --parents ${{ secrets.TARGET_DIRECTORY }}/oldVersions/$(date +%Y%m%d_%H%M%S) && mv ${{ secrets.TARGET_DIRECTORY }}/BabysBaby.jar $_ | |
host: ${{ secrets.VSOS_IP_ADDRESS }} | |
username: ${{ secrets.USERNAME }} | |
privateKey: ${{ secrets.SSH_KEY }} | |
- name: Deploy BabysBaby.jar to server | |
uses: garygrossgarten/github-action-scp@release | |
with: | |
atomicPut: true | |
local: staging/BabysBaby-0.0.1-SNAPSHOT-jar-with-dependencies.jar | |
remote: ${{ secrets.TARGET_DIRECTORY }}/BabysBaby.jar | |
host: ${{ secrets.VSOS_IP_ADDRESS }} | |
username: ${{ secrets.USERNAME }} | |
privateKey: ${{ secrets.SSH_KEY }} | |
- name: Restart the BabysBaby service | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: sudo systemctl restart BabysBaby | |
host: ${{ secrets.VSOS_IP_ADDRESS }} | |
username: ${{ secrets.USERNAME }} | |
privateKey: ${{ secrets.SSH_KEY }} |