-
Notifications
You must be signed in to change notification settings - Fork 3
76 lines (66 loc) · 2.64 KB
/
master-push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Builds pushes and merges on develop branch
name: Master branch build, test, deploy
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.5.0
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/cache@v2
name: Cache gradle dependencies
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set short git commit SHA
id: vars
run: echo "::set-output name=sha_short::$(./gradlew :administration:printCommitSha | grep COMMIT | cut -d":" -f2)"
- uses: actions/cache@v2
name: Cache NPM dependencies
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build project backend module and run tests
run: ./gradlew clean syncNpm test bootJar buildImage
- name: Save docker image for DEMO
run: |
docker save -o timetracker-backend.img ua-timetracker/time-tracker:${{ steps.vars.outputs.sha_short }}
docker save -o timetracker-worker.img ua-timetracker/worker:${{ steps.vars.outputs.sha_short }}
docker save -o timetracker-ui.img ua-timetracker/time-tracker-ui:${{ steps.vars.outputs.sha_short }}
docker save -o timetracker-admin.img ua-timetracker/administration:${{ steps.vars.outputs.sha_short }}
- name: Copy docker-image to DEMO
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEMO_HOST }}
username: ${{ secrets.DEMO_USERNAME }}
key: ${{ secrets.DEMO_CI_CD_PRIVATE_KEY }}
source: "*.img"
target: "apps/timetracker"
overwrite: true
- name: Deploy new docker image on DEMO
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEMO_HOST }}
username: ${{ secrets.DEMO_USERNAME }}
key: ${{ secrets.DEMO_CI_CD_PRIVATE_KEY }}
script: |
ls -1 apps/timetracker/*.img | xargs --no-run-if-empty -L 1 docker load -i
echo "export TIMETRACKER_LATEST=${{ steps.vars.outputs.sha_short }}" > ./time-tracker-version.sh
. ./all-env.sh
docker stack deploy --compose-file docker-compose.yml base-demo