-
Notifications
You must be signed in to change notification settings - Fork 5
191 lines (179 loc) · 8.04 KB
/
build-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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Build and push
on:
pull_request_target:
branches: [ "main" ]
types:
- closed
workflow_dispatch:
jobs:
build_api:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build app image
run: docker build . --tag image
- name: Log into registry
run: echo "${{ secrets.REGISTRYPASSWORD }}" | docker login registry.nordix.org -u ${{ secrets.REGISTRYUSERNAME }} --password-stdin
- name: Push app image
id: image
run: |
IMAGE_ID=registry.nordix.org/eiffel/etos-api
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo $IMAGE_ID:$VERSION
echo "::set-output name=version::$VERSION"
outputs:
apiVersion: ${{ steps.image.outputs.version }}
build_sse:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build app image
run: docker build . -f deploy/etos-sse/Dockerfile --tag image
- name: Log into registry
run: echo "${{ secrets.REGISTRYPASSWORD }}" | docker login registry.nordix.org -u ${{ secrets.REGISTRYUSERNAME }} --password-stdin
- name: Push app image
id: image
run: |
IMAGE_ID=registry.nordix.org/eiffel/etos-sse
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo $IMAGE_ID:$VERSION
echo "::set-output name=version::$VERSION"
outputs:
sseVersion: ${{ steps.image.outputs.version }}
build_logarea:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build app image
run: docker build . -f deploy/etos-logarea/Dockerfile --tag image
- name: Log into registry
run: echo "${{ secrets.REGISTRYPASSWORD }}" | docker login registry.nordix.org -u ${{ secrets.REGISTRYUSERNAME }} --password-stdin
- name: Push app image
id: image
run: |
IMAGE_ID=registry.nordix.org/eiffel/etos-logarea
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo $IMAGE_ID:$VERSION
echo "::set-output name=version::$VERSION"
outputs:
logAreaVersion: ${{ steps.image.outputs.version }}
build_iut:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build app image
run: docker build . -f deploy/etos-iut/Dockerfile --tag image
- name: Log into registry
run: echo "${{ secrets.REGISTRYPASSWORD }}" | docker login registry.nordix.org -u ${{ secrets.REGISTRYUSERNAME }} --password-stdin
- name: Push app image
id: image
run: |
IMAGE_ID=registry.nordix.org/eiffel/etos-iut
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo $IMAGE_ID:$VERSION
echo "::set-output name=version::$VERSION"
outputs:
iutVersion: ${{ steps.image.outputs.version }}
build_executionspace:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build app image
run: docker build . -f deploy/etos-executionspace/Dockerfile --tag image
- name: Log into registry
run: echo "${{ secrets.REGISTRYPASSWORD }}" | docker login registry.nordix.org -u ${{ secrets.REGISTRYUSERNAME }} --password-stdin
- name: Push app image
id: image
run: |
IMAGE_ID=registry.nordix.org/eiffel/etos-executionspace
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=$(echo ${{ github.sha }} | cut -c1-8)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo $IMAGE_ID:$VERSION
echo "::set-output name=version::$VERSION"
outputs:
executionSpaceVersion: ${{ steps.image.outputs.version }}
update_manifests:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
needs: [build_api, build_sse, build_logarea, build_iut, build_executionspace]
steps:
- uses: actions/checkout@v3
- name: Update manifests
uses: fjogeleit/yaml-update-action@main
with:
changes: |
{
"manifests/base/sse/deployment.yaml": {
"spec.template.spec.containers[0].image": "registry.nordix.org/eiffel/etos-sse:${{ needs.build_sse.outputs.sseVersion }}"
},
"manifests/base/deployment.yaml": {
"spec.template.spec.containers[0].image": "registry.nordix.org/eiffel/etos-api:${{ needs.build_api.outputs.apiVersion }}"
},
"manifests/base/logarea/deployment.yaml": {
"spec.template.spec.containers[0].image": "registry.nordix.org/eiffel/etos-logarea:${{ needs.build_logarea.outputs.logAreaVersion }}"
},
"manifests/base/iut/deployment.yaml": {
"spec.template.spec.containers[0].image": "registry.nordix.org/eiffel/etos-iut:${{ needs.build_iut.outputs.iutVersion }}"
},
"manifests/base/executionspace/deployment.yaml": {
"spec.template.spec.containers[0].image": "registry.nordix.org/eiffel/etos-executionspace:${{ needs.build_executionspace.outputs.executionSpaceVersion }}"
}
}
branch: main
commitChange: true
message: |
Updating ETOS images:
- SSE: ${{ needs.build_sse.outputs.sseVersion }}
- LogArea: ${{ needs.build_logarea.outputs.logAreaVersion }}
- IUT: ${{ needs.build_iut.outputs.iutVersion }}
- Execution Space: ${{ needs.build_executionspace.outputs.executionSpaceVersion }}
- API: ${{ needs.build_api.outputs.apiVersion }}