-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (172 loc) · 5.95 KB
/
build-docker-images.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
192
193
194
195
196
197
198
199
200
201
name: Docker Image CI
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
OPENEM_FLOWS_IMAGE_NAME: ${{ github.repository }}-openem-flows
OPENEM_BACKEND_IMAGE_NAME: ${{ github.repository }}-openem-backend
OPENEM_CONFIG_IMAGE_NAME: ${{ github.repository }}-openem-config
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
detect_changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
backend: ${{ steps.filter.outputs.backend }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: actions/checkout@v4
if: github.event_name != 'pull_request'
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'backend/**'
# test_api_server:
# runs-on: ubuntu-latest
# needs: detect_changes
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: '3.11'
# - name: Install dependencies and run tests
# working-directory: ./backend/api/src/openapi_server
# run: |
# python -m pip install --upgrade pip
# python -m pip install pipenv
# pipenv sync
# pipenv run pytest --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
# - name: Upload pytest test results
# uses: actions/upload-artifact@v4
# with:
# name: api-test-results
# path: ./backend/junit/test-results.xml
# # Use always() to always run this step to publish test results when there are test failures
# if: ${{ always() }}
#
test_archiver_flows:
runs-on: ubuntu-latest
needs: detect_changes
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies and run tests
working-directory: ./backend/archiver
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
pipenv sync -d
pipenv run pytest --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: archiver-test-results
path: ./junit/test-results.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
build_runtime_image:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
needs: test_archiver_flows
if: ${{ needs.detect_changes.outputs.backend == 'true' }} || github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Log into registry ${{ env.REGISTRY }}
# if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.OPENEM_FLOWS_IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: ./
file: ./backend/prefect-runtime.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
build-args: PREFECT_VERSION=3.0.4-python3.11
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build_config_image:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
needs: test_archiver_flows
if: ${{ needs.detect_changes.outputs.backend == 'true' }} || github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Log into registry ${{ env.REGISTRY }}
# if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.OPENEM_CONFIG_IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: ./backend/
file: ./backend/prefect-config.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
build-args: PREFECT_VERSION=3.0.4-python3.11
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build_openem_backend:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
# needs: test_api_server
if: ${{ needs.detect_changes.outputs.backend == 'true' }} || github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Log into registry ${{ env.REGISTRY }}
# if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.OPENEM_BACKEND_IMAGE_NAME }}
- name: Build and push
uses: docker/bake-action@v5
id: build-and-push
with:
workdir: ./
targets: archiver-backend
push: ${{ github.event_name != 'pull_request' }}
set: |
*.tags=${{ steps.meta.outputs.tags }}