-
Notifications
You must be signed in to change notification settings - Fork 14
176 lines (158 loc) · 5.65 KB
/
bld_docker_jib.yml
File metadata and controls
176 lines (158 loc) · 5.65 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: bld_docker_jib
run-name: ${{ inputs.docker_name }}
permissions:
checks: write
contents: read
issues: read
pull-requests: write
on:
workflow_call:
inputs:
docker_name:
description: 'Name of the docker image to build'
required: false
default: "memberservice"
type: string
context:
description: 'Name of the context in the repo'
required: false
default: "."
type: string
version_tag:
description: 'Name of the tag to build'
required: false
default: '0.0.1-dev'
type: string
bump:
description: 'whether to bump the version number by a major minor patch amount or none'
required: false
default: 'patch'
type: string
ref:
description: 'git reference to use with the checkout use default_branch to have that calculated'
required: false
default: "default"
type: string
angular_env:
description: 'Name of the angular environment to build'
required: false
default: 'unused'
type: string
workflow_dispatch:
inputs:
docker_name:
description: 'Name of the docker image to build'
required: false
default: "memberservice"
type: string
context:
description: 'Name of the context in the repo'
required: false
default: "."
type: string
version_tag:
description: 'Name of the tag to build'
required: false
default: '0.0.1-dev'
type: string
bump:
description: |
How to optionally bump the semver version ( Major.Minor.Patch ) : git log will be searched for
'#major #minor #patch' or feat/ or fix/ branch names to optionally override the bump. Set to none to keep a specific version
required: false
options:
- patch
- minor
- major
- none
type: choice
ref:
description: 'git reference to use with the checkout use default_branch to have that calculated'
required: false
default: "default"
type: string
angular_env:
description: 'Name of the angular environment to build'
required: false
default: 'unused'
type: string
jobs:
bld_docker:
runs-on: ubuntu-latest
steps:
- name: git-checkout-ref-action
id: ref
uses: ORCID/git-checkout-ref-action@main
with:
default_branch: ${{ github.event.repository.default_branch }}
ref: ${{ inputs.ref }}
- uses: actions/checkout@v3
with:
ref: ${{ steps.ref.outputs.ref }}
# checkout some history so we can scan commits for bump messages
# NOTE: history does not include tags!
fetch-depth: 100
# - name: find next version
# id: version
# uses: ORCID/version-bump-action@main
# with:
# version_tag: ${{ inputs.version_tag }}
# bump: ${{ inputs.bump }}
# with jib we are building outside the container and using mvn??
- name: Set up Open JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
##############################################################################################
- name: build our project
working-directory: ${{ inputs.context }}
run: |
#mvn -T 1C --batch-mode -am package -DskipTests \
#-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
mvn -T 1C -Pprod --batch-mode -am verify \
jib:dockerBuild -Drelease.tag=${tag} -DDOCKER_REG=${DOCKER_REG_PRIVATE} -Dangular.env=${angular_env}
echo "------------------------------------------------------"
find . -name '*.war'
find . -name '*.jar'
docker image ls
shell: bash
env:
DOCKER_REG_PRIVATE: "${{ secrets.DOCKER_REG_PRIVATE }}"
#tag: "${{ steps.version.outputs.version_tag }}"
tag: "${{ inputs.version_tag }}"
angular_env: "${{ inputs.angular_env }}"
- name: Login to private registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_REG_PRIVATE }}
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
#############################################################################################
- name: push our container to the private registry
if: inputs.angular_env == 'unused'
run: |
docker push ${DOCKER_REG_PRIVATE}/${docker_name}:${tag}
shell: bash
env:
DOCKER_REG_PRIVATE: "${{ secrets.DOCKER_REG_PRIVATE }}"
docker_name: "${{ inputs.docker_name }}"
#version_tag: "${{ steps.version.outputs.version_tag }}"
tag: "${{ inputs.version_tag }}"
- name: push our container to the private registry using a postpended tag of the angular env
if: inputs.angular_env != 'unused'
run: |
docker push ${DOCKER_REG_PRIVATE}/${docker_name}:${tag}
shell: bash
env:
DOCKER_REG_PRIVATE: "${{ secrets.DOCKER_REG_PRIVATE }}"
docker_name: "${{ inputs.docker_name }}"
#version_tag: "${{ steps.version.outputs.version_tag }}"
tag: "${{ inputs.version_tag }}-${{ inputs.angular_env }}"