2021-10-04 07:13:00 +00:00
|
|
|
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
|
|
|
|
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
|
|
|
|
|
|
|
|
name: Build and Deploy
|
|
|
|
|
|
|
|
on:
|
2021-10-14 15:49:09 +00:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2021-10-04 07:13:00 +00:00
|
|
|
|
2021-10-14 15:49:09 +00:00
|
|
|
workflow_dispatch:
|
2021-10-06 08:23:17 +00:00
|
|
|
|
2021-10-04 07:13:00 +00:00
|
|
|
jobs:
|
2021-10-14 15:49:09 +00:00
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
2021-10-04 07:13:00 +00:00
|
|
|
|
2021-10-14 15:49:09 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Set up JDK 11
|
|
|
|
uses: actions/setup-java@v2
|
|
|
|
with:
|
|
|
|
java-version: "11"
|
|
|
|
distribution: "adopt"
|
2021-10-06 08:23:17 +00:00
|
|
|
|
2021-10-14 15:49:09 +00:00
|
|
|
- run: mkdir ./target
|
2021-10-04 07:13:00 +00:00
|
|
|
|
2021-10-14 15:49:09 +00:00
|
|
|
- name: Cache Maven packages
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: ~/.m2
|
|
|
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
|
|
|
restore-keys: ${{ runner.os }}-m2
|
2021-10-04 07:13:00 +00:00
|
|
|
|
2021-11-15 10:59:27 +00:00
|
|
|
- name: Build common library
|
|
|
|
run: mvn -f common/pom.xml --batch-mode --update-snapshots install
|
2021-10-04 07:13:00 +00:00
|
|
|
|
2021-11-15 10:59:27 +00:00
|
|
|
- name: Build roster service
|
|
|
|
run: mvn -f roster/pom.xml --batch-mode --update-snapshots verify
|
|
|
|
- run: cp ./roster/target/roster-0.0.1-SNAPSHOT.jar ./target
|
|
|
|
|
|
|
|
- name: Build executor-pool service
|
2021-10-14 15:49:09 +00:00
|
|
|
run: mvn -f executor-pool/pom.xml --batch-mode --update-snapshots verify
|
2021-10-17 13:53:36 +00:00
|
|
|
- run: cp ./executor-pool/target/executor-pool-0.0.1-SNAPSHOT.jar ./target
|
2021-10-04 07:13:00 +00:00
|
|
|
|
2021-11-15 10:59:27 +00:00
|
|
|
- name: Build executor-base library
|
2021-10-17 13:57:01 +00:00
|
|
|
run: mvn -f executor-base/pom.xml --batch-mode --update-snapshots install
|
2021-10-17 13:38:04 +00:00
|
|
|
|
2021-11-15 10:59:27 +00:00
|
|
|
- name: Build executor-computation service
|
|
|
|
run: mvn -f executor-computation/pom.xml --batch-mode --update-snapshots verify
|
|
|
|
- run: cp ./executor-computation/target/executor-computation-0.0.1-SNAPSHOT.jar ./target
|
2021-10-04 07:13:00 +00:00
|
|
|
|
2021-11-15 10:59:27 +00:00
|
|
|
- name: Build executor-robot service
|
|
|
|
run: mvn -f executor-robot/pom.xml --batch-mode --update-snapshots verify
|
|
|
|
- run: cp ./executor-robot/target/executor-robot-0.0.1-SNAPSHOT.jar ./target
|
2021-10-14 15:49:09 +00:00
|
|
|
|
2021-12-18 15:18:54 +00:00
|
|
|
- name: Build executor-humidity service
|
|
|
|
run: mvn -f executor-humidity/pom.xml --batch-mode --update-snapshots verify
|
|
|
|
- run: cp ./executor-humidity/target/executor-humidity-0.0.1-SNAPSHOT.jar ./target
|
|
|
|
|
2021-11-15 10:59:27 +00:00
|
|
|
- name: Build tapas-task service
|
2021-10-14 15:49:09 +00:00
|
|
|
run: mvn -f tapas-tasks/pom.xml --batch-mode --update-snapshots verify
|
2021-10-17 13:53:36 +00:00
|
|
|
- run: cp ./tapas-tasks/target/tapas-tasks-0.0.1-SNAPSHOT.jar ./target
|
2021-10-14 15:49:09 +00:00
|
|
|
|
2021-11-15 10:59:27 +00:00
|
|
|
- name: Build tapas-auction-house service
|
2021-10-18 09:45:52 +00:00
|
|
|
run: mvn -f tapas-auction-house/pom.xml --batch-mode --update-snapshots verify
|
|
|
|
- run: cp ./tapas-auction-house/target/tapas-auction-house-0.0.1-SNAPSHOT.jar ./target
|
|
|
|
|
2021-10-14 15:49:09 +00:00
|
|
|
- run: cp ./.deployment/docker-compose.yml ./target
|
|
|
|
- name: Archive artifacts
|
|
|
|
uses: actions/upload-artifact@v1
|
|
|
|
with:
|
|
|
|
name: app
|
|
|
|
path: ./target/
|
|
|
|
|
|
|
|
deploy:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [build]
|
|
|
|
steps:
|
|
|
|
- name: Download app artifacts
|
|
|
|
uses: actions/download-artifact@v1
|
|
|
|
with:
|
|
|
|
name: app
|
|
|
|
- name: Copy host via scp
|
|
|
|
uses: appleboy/scp-action@master
|
|
|
|
env:
|
|
|
|
HOST: ${{ secrets.SSH_HOST }}
|
|
|
|
USERNAME: ${{ secrets.SSH_USER }}
|
|
|
|
PORT: 22
|
|
|
|
KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
|
|
with:
|
|
|
|
source: "app/*"
|
|
|
|
target: "/home/${{ secrets.SSH_USER }}/"
|
|
|
|
strip_components: 1
|
|
|
|
rm: false
|
|
|
|
overwrite: true
|
|
|
|
|
|
|
|
- name: Executing remote command
|
|
|
|
uses: appleboy/ssh-action@master
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.SSH_HOST }}
|
|
|
|
USERNAME: ${{ secrets.SSH_USER }}
|
|
|
|
PORT: 22
|
|
|
|
KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
|
|
script: |
|
|
|
|
cd /home/${{ secrets.SSH_USER }}/
|
|
|
|
touch acme.json
|
|
|
|
sudo chmod 0600 acme.json
|
2021-12-21 14:30:33 +00:00
|
|
|
sudo docker-compose down --remove-orphans
|
2021-10-14 15:49:09 +00:00
|
|
|
sudo echo "PUB_IP=$(wget -qO- http://ipecho.net/plain | xargs echo)" | sed -e 's/\./-/g' > .env
|
2021-12-21 14:30:33 +00:00
|
|
|
sudo docker-compose up -d
|