generated from KvalitetsIT/kithugs
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (80 loc) · 3.76 KB
/
build.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: CICD
on:
push:
branches: [ main ]
tags:
- 'v*.*.*'
jobs:
build:
runs-on: ubuntu-latest
steps:
# Set docker image names.
- name: Setup env variables
run: |
echo "DOCKER_SERVICE=kvalitetsit/kithugs" >> $GITHUB_ENV
echo "DOCKER_DOCUMENTATION=kvalitetsit/kithugs-documentation" >> $GITHUB_ENV
# Checkout source code
- uses: actions/checkout@v3
# Fail if DOCKER_SERVICE is kithugs and repo is not kithugs. This step can be deleted once
- name: Initial build
run: ./build/failOnFirstBuild.sh
# Cache maven stuff
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# if below step is skipped this build is a tag build. Can be used for skipping other steps.
- name: Is Tag Build
id: tag
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
# Login to docker hub using secrets in GitHub.
- name: Login to docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and test
run: ./build/build.sh
- name: Tag service dev docker image
run: ./build/docker-tag.sh ${{ env.DOCKER_SERVICE }}:latest ${{ env.DOCKER_SERVICE }}:dev
- name: Push service dev docker image
run: ./build/docker-push.sh ${{ env.DOCKER_SERVICE }}:dev
- name: Tag service git id docker image
run: ./build/docker-tag.sh ${{ env.DOCKER_SERVICE }}:latest ${{ env.DOCKER_SERVICE }}:${{ github.sha }}
- name: Push service git id docker image.
run: ./build/docker-push.sh ${{ env.DOCKER_SERVICE }}:${{ github.sha }}
- name: Tag documentation dev docker image
run: ./build/docker-tag.sh ${{ env.DOCKER_DOCUMENTATION }}:latest ${{ env.DOCKER_DOCUMENTATION }}:dev
- name: Push documentation dev docker image
run: ./build/docker-push.sh ${{ env.DOCKER_DOCUMENTATION }}:dev
- name: Tag documentation git id docker image
run: ./build/docker-tag.sh ${{ env.DOCKER_DOCUMENTATION }}:latest ${{ env.DOCKER_DOCUMENTATION }}:${{ github.sha }}
- name: Push documentation git id docker image.
run: ./build/docker-push.sh ${{ env.DOCKER_DOCUMENTATION }}:${{ github.sha }}
- name: Push latest service docker image
if: ${{ steps.tag.conclusion != 'skipped' }}
run: ./build/docker-push.sh ${{ env.DOCKER_SERVICE }}:latest
- name: Tag version service docker image
if: ${{ steps.tag.conclusion != 'skipped' }}
run: ./build/docker-tag.sh ${{ env.DOCKER_SERVICE }}:latest ${{ env.DOCKER_SERVICE }}:${{ steps.tag.outputs.VERSION }}
- name: Push version service docker image.
if: ${{ steps.tag.conclusion != 'skipped' }}
run: ./build/docker-push.sh ${{ env.DOCKER_SERVICE }}:${{ steps.tag.outputs.VERSION }}
- name: Push latest documentation docker image
if: ${{ steps.tag.conclusion != 'skipped' }}
run: ./build/docker-push.sh ${{ env.DOCKER_DOCUMENTATION }}:latest
- name: Tag version documentation docker image
if: ${{ steps.tag.conclusion != 'skipped' }}
run: ./build/docker-tag.sh ${{ env.DOCKER_DOCUMENTATION }}:latest ${{ env.DOCKER_DOCUMENTATION }}:${{ steps.tag.outputs.VERSION }}
- name: Push version documentation docker image.
if: ${{ steps.tag.conclusion != 'skipped' }}
run: ./build/docker-push.sh ${{ env.DOCKER_DOCUMENTATION }}:${{ steps.tag.outputs.VERSION }}
- name: Create Release Notes
uses: softprops/action-gh-release@v1
if: ${{ steps.tag.conclusion != 'skipped' }}
with:
generate_release_notes: true