Skip to content

Commit 2ca69ed

Browse files
always build all devcontainers together. Add in conditional needs.
1 parent 062fe2e commit 2ca69ed

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

.github/workflows/cicd.yaml

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ env:
3131
node_version: 24
3232
temp_dockerfile: /tmp/Dockerfile.source
3333
image_prefix: nhsdigital/nhs-notify-devcontainer-
34+
workflow_path: .github/workflows/cicd.yaml
35+
3436
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
3537
jobs:
3638
deploy-nhs-notify-feature:
@@ -48,6 +50,8 @@ jobs:
4850
filters: |
4951
src:
5052
- '${{ env.features_dir }}/**'
53+
- '${{ env.workflow_path }}'
54+
5155
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
5256
name: "Publish Features"
5357
uses: devcontainers/action@v1
@@ -58,7 +62,24 @@ jobs:
5862
env:
5963
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6064

65+
check-if-changed:
66+
needs: deploy-nhs-notify-feature
67+
if: needs.deploy-nhs-notify-feature.result == 'success' || needs.deploy-nhs-notify-feature.result == 'skipped'
68+
runs-on: ubuntu-latest
69+
outputs:
70+
src: ${{ steps.changes.outputs.src }}
71+
steps:
72+
- uses: dorny/paths-filter@v3
73+
id: changes
74+
with:
75+
filters: |
76+
src:
77+
- '${{env.base_dir}}/**'
78+
- '${{ env.workflow_path }}'
79+
6180
build-and-push-image:
81+
if: needs.check-if-changed.outputs.src == 'true'
82+
needs: check-if-changed
6283
runs-on: ubuntu-latest
6384
strategy:
6485
fail-fast: false
@@ -75,8 +96,6 @@ jobs:
7596
title: NHS Notifiy Devcontainer Loaded Image
7697
description: Loaded development container for NHS Notify projects
7798

78-
79-
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
8099
permissions:
81100
contents: read
82101
packages: write
@@ -86,29 +105,19 @@ jobs:
86105
steps:
87106
- name: Checkout repository
88107
uses: actions/checkout@v5
89-
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
90108

91-
- uses: dorny/paths-filter@v3
92-
id: changes
93-
with:
94-
filters: |
95-
src:
96-
- '${{env.base_dir}}/${{ matrix.container_name }}/**'
97-
98-
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
99-
name: Log in to the Container registry
109+
- name: Log in to the Container registry
100110
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
101111
with:
102112
registry: ${{ env.registry }}
103113
username: ${{ github.actor }}
104114
password: ${{ secrets.GITHUB_TOKEN }}
105115

106-
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
107-
uses: actions/setup-node@v6
116+
- uses: actions/setup-node@v6
108117
with:
109118
node-version: ${{ env.node_version }}
110119

111-
- if: steps.changes.outputs.src == 'true' && !startsWith(github.ref, 'refs/tags/v')
120+
- if: ! startsWith(github.ref, 'refs/tags/v')
112121
name: Build default
113122
working-directory: ${{env.base_dir}}/${{ matrix.container_name }}
114123
run: |
@@ -124,8 +133,7 @@ jobs:
124133
make build BASE_IMAGE_TAG=$TAG_VERSION IMAGE_NAME=${{ env.registry }}/${{ env.image_prefix }}${{ matrix.container_name }} WORKSPACE_FOLDER=${{ env.workspace_folder }}
125134
126135
127-
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
128-
name: Extract metadata (tags, labels) for Docker
136+
- name: Extract metadata (tags, labels) for Docker
129137
id: meta
130138
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
131139
with:
@@ -147,12 +155,10 @@ jobs:
147155
org.opencontainers.image.url=${{ env.server }}/${{ env.org }}/${{ env.repository }}/blob/main/${{ env.base_dir }}/${{matrix.container_name}}/${{ env.readme }}
148156
org.opencontainers.image.source=${{ env.server }}/${{ env.org }}/${{ env.repository }}/tree/main/${{ env.base_dir }}/${{matrix.container_name}}/
149157
150-
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
151-
name: create temp dockerfile source
158+
- name: create temp dockerfile source
152159
run: echo 'FROM ${{ env.registry }}/${{ env.image_prefix }}${{ matrix.container_name }}' > ${{ env.temp_dockerfile }}
153160

154-
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
155-
name: Build and push Docker image
161+
- name: Build and push Docker image
156162
id: push
157163
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
158164
with:
@@ -162,8 +168,7 @@ jobs:
162168
tags: ${{ steps.meta.outputs.tags }}
163169
labels: ${{ steps.meta.outputs.labels }}
164170

165-
- if: steps.changes.outputs.src == 'true' || startsWith(github.ref, 'refs/tags/v')
166-
name: Generate artifact attestation
171+
- name: Generate artifact attestation
167172
uses: actions/attest-build-provenance@v3
168173
with:
169174
subject-name: ${{ env.registry }}/${{ env.image_prefix }}${{ matrix.container_name }}

src/devcontainers/loaded/.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"postStartCommand": "echo ${localEnv:CONTAINER_NAME} Started",
1414

1515
"features": {
16-
"ghcr.io/nhsdigital/nhs-notify-devcontainers/nhsnotify:1.0.20": {}
16+
"ghcr.io/nhsdigital/nhs-notify-devcontainers/nhsnotify:1.0.21": {}
1717
},
1818
"runArgs": [
1919
"--platform=linux/amd64"

src/features/nhsnotify/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"id": "nhsnotify",
99
"name": "NHS Notify",
10-
"version": "1.0.20",
10+
"version": "1.0.21",
1111
"dependsOn": {
1212
"ghcr.io/devcontainers/features/common-utils:2.5.4": {
1313
"configureZshAsDefaultShell": true,

0 commit comments

Comments
 (0)