-
Notifications
You must be signed in to change notification settings - Fork 1
196 lines (174 loc) · 7.04 KB
/
docker-build-bops.yml
File metadata and controls
196 lines (174 loc) · 7.04 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Build and publish BOPS container images to ghcr.io
#
# Builds two images in parallel:
# - ghcr.io/co-cddo/ndx_try_aws_scenarios-bops:latest (back-office + worker)
# - ghcr.io/co-cddo/ndx_try_aws_scenarios-bops-applicants:latest (public portal)
#
# Both clone their upstream repos at pinned commits, apply our overlay files,
# and build using the upstream Dockerfile.production.
name: Build BOPS Container Images
on:
push:
branches: [main, feat/bops-planning]
paths:
- 'cloudformation/scenarios/bops-planning/docker/**'
- '.github/workflows/docker-build-bops.yml'
pull_request:
paths:
- 'cloudformation/scenarios/bops-planning/docker/**'
- '.github/workflows/docker-build-bops.yml'
workflow_dispatch:
inputs:
push_image:
description: 'Push images to registry'
required: false
default: true
type: boolean
env:
REGISTRY: ghcr.io
# Pin to specific commits for reproducibility — update these when upgrading BOPS
BOPS_REPO: unboxed/bops
BOPS_COMMIT: main
BOPS_APPLICANTS_REPO: unboxed/bops-applicants
BOPS_APPLICANTS_COMMIT: main
jobs:
changes:
name: Check for Docker changes
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
outputs:
docker: ${{ steps.filter.outputs.docker }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
docker:
- 'cloudformation/scenarios/bops-planning/docker/**'
- '.github/workflows/docker-build-bops.yml'
build-bops:
name: Build BOPS Back-Office
runs-on: ubuntu-latest
needs: [changes]
if: |
always() &&
(needs.changes.result == 'skipped' || needs.changes.outputs.docker == 'true')
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Clone BOPS source
run: |
git clone --depth 1 https://github.com/${{ env.BOPS_REPO }}.git bops-src
if [ "${{ env.BOPS_COMMIT }}" != "main" ]; then
cd bops-src
git fetch --depth 1 origin ${{ env.BOPS_COMMIT }}
git checkout ${{ env.BOPS_COMMIT }}
cd ..
fi
- name: Copy overlay files
run: |
mkdir -p bops-src/scripts
cp cloudformation/scenarios/bops-planning/docker/bops/config/initializers/default_local_authority.rb bops-src/config/initializers/
cp cloudformation/scenarios/bops-planning/docker/bops/scripts/seed_sample_data.rb bops-src/scripts/
cp cloudformation/scenarios/bops-planning/docker/bops/scripts/seed-entrypoint.sh bops-src/scripts/
cp cloudformation/scenarios/bops-planning/docker/bops/scripts/init-bops.sh bops-src/scripts/
cp cloudformation/scenarios/bops-planning/docker/bops/entrypoint.sh bops-src/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/co-cddo/ndx_try_aws_scenarios-bops
tags: |
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }}
- name: Build and push BOPS image
uses: docker/build-push-action@v7
with:
context: bops-src
file: bops-src/Dockerfile.production
push: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feat/bops-planning' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image != 'false')) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=bops
cache-to: type=gha,mode=max,scope=bops
platforms: linux/amd64
- name: Output image details
run: |
echo "## BOPS Image Built" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
build-bops-applicants:
name: Build BOPS Applicants Portal
runs-on: ubuntu-latest
needs: [changes]
if: |
always() &&
(needs.changes.result == 'skipped' || needs.changes.outputs.docker == 'true')
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Clone BOPS-Applicants source
run: |
git clone --depth 1 https://github.com/${{ env.BOPS_APPLICANTS_REPO }}.git bops-applicants-src
if [ "${{ env.BOPS_APPLICANTS_COMMIT }}" != "main" ]; then
cd bops-applicants-src
git fetch --depth 1 origin ${{ env.BOPS_APPLICANTS_COMMIT }}
git checkout ${{ env.BOPS_APPLICANTS_COMMIT }}
cd ..
fi
- name: Copy overlay files
run: |
cp cloudformation/scenarios/bops-planning/docker/bops-applicants/config/initializers/default_local_authority.rb bops-applicants-src/config/initializers/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/co-cddo/ndx_try_aws_scenarios-bops-applicants
tags: |
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }}
- name: Build and push BOPS-Applicants image
uses: docker/build-push-action@v7
with:
context: bops-applicants-src
file: bops-applicants-src/Dockerfile.production
push: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feat/bops-planning' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image != 'false')) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=bops-applicants
cache-to: type=gha,mode=max,scope=bops-applicants
platforms: linux/amd64
- name: Output image details
run: |
echo "## BOPS-Applicants Image Built" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY