Skip to content

Commit c9f328a

Browse files
committed
updates
1 parent 0ee2eca commit c9f328a

6 files changed

Lines changed: 103 additions & 46 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ jobs:
5656
runtime_docker_image: "${{ needs.get_config_values.outputs.devcontainer_image }}:githubactions-${{ needs.get_config_values.outputs.devcontainer_version }}"
5757
branch_name: ${{ github.event.pull_request.head.ref }}
5858
tag_format: ${{ needs.get_config_values.outputs.tag_format }}
59-
use_published_from_main_image: false
59+
verify_published_from_main_image: false
6060
secrets: inherit

.github/workflows/quality-checks-devcontainer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: ./.github/workflows/verify-attestation.yml
3131
with:
3232
runtime_docker_image: "${{ inputs.runtime_docker_image }}"
33-
use_published_from_main_image: false
33+
verify_published_from_main_image: false
3434
quality_checks:
3535
runs-on: ubuntu-22.04
3636
needs: verify_attestation

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ jobs:
4444
runtime_docker_image: "${{ needs.get_config_values.outputs.devcontainer_image }}:githubactions-${{ needs.get_config_values.outputs.devcontainer_version }}"
4545
branch_name: main
4646
tag_format: ${{ needs.get_config_values.outputs.tag_format }}
47-
use_published_from_main_image: true
47+
verify_published_from_main_image: true
4848
secrets: inherit

.github/workflows/tag-release-devcontainer.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ on:
4545
description: "An repository for the extra artifact"
4646
required: false
4747
type: string
48-
use_published_from_main_image:
48+
verify_published_from_main_image:
4949
required: true
5050
type: boolean
5151
outputs:
@@ -66,7 +66,7 @@ jobs:
6666
uses: ./.github/workflows/verify-attestation.yml
6767
with:
6868
runtime_docker_image: "${{ inputs.runtime_docker_image }}"
69-
use_published_from_main_image: ${{ inputs.use_published_from_main_image }}
69+
verify_published_from_main_image: ${{ inputs.verify_published_from_main_image }}
7070
tag_release:
7171
runs-on: ubuntu-22.04
7272
needs: verify_attestation

.github/workflows/verify-attestation.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ name: Verify image digest and attestation
1818
required: false
1919
type: string
2020
default: NHSDigital
21-
use_published_from_main_image:
21+
verify_published_from_main_image:
2222
required: false
2323
type: boolean
2424
default: true
@@ -94,15 +94,15 @@ jobs:
9494
env:
9595
GH_TOKEN: ${{ github.token }}
9696
OWNER: ${{ inputs.owner }}
97-
USE_PUBLISHED_FROM_MAIN_IMAGE: ${{ inputs.use_published_from_main_image }}
97+
VERIFY_PUBLISHED_FROM_MAIN_IMAGE: ${{ inputs.verify_published_from_main_image }}
9898
PREDICATE_TYPE: ${{ inputs.predicate_type }}
9999
PINNED_IMAGE: ${{ steps.resolve.outputs.pinned_image }}
100100
run: |
101101
set -euo pipefail
102102
103103
args=("oci://${PINNED_IMAGE}" "--owner" "$OWNER" "--predicate-type" "$PREDICATE_TYPE")
104104
105-
if [[ "$USE_PUBLISHED_FROM_MAIN_IMAGE" == "true" ]]; then
105+
if [[ "$VERIFY_PUBLISHED_FROM_MAIN_IMAGE" == "true" ]]; then
106106
args+=("--source-ref" "refs/heads/main")
107107
fi
108108

README.md

Lines changed: 95 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,25 @@ A collection of common workflows used by other EPS repositories
44

55
The workflows that are available to use are
66

7-
## Adding exclusions to trivy scanning
8-
The quality checks job uses trivy to scan for vulnerabilities.
7+
## Workflow Index
8+
9+
- [Combine Dependabot PRs](#combine-dependabot-prs)
10+
- [Dependabot Auto Approve and Merge](#dependabot-auto-approve-and-merge)
11+
- [PR Title Check](#pr-title-check)
12+
- [Quality Checks](#quality-checks)
13+
- [Quality Checks - Dev Container Version](#quality-checks---dev-container-version)
14+
- [Verify Image Digest and Attestation](#verify-image-digest-and-attestation)
15+
- [Tag Release](#tag-release)
16+
- [Tag Release - Devcontainer Version](#tag-release---devcontainer-version)
17+
18+
## Other Docs
19+
20+
- [Adding Exclusions to Trivy Scanning](#adding-exclusions-to-trivy-scanning)
21+
- [Secret Scanning Docker](#secret-scanning-docker)
22+
- [Run All Releases](#run-all-releases)
23+
24+
## Adding Exclusions to Trivy Scanning
25+
The quality checks job uses Trivy to scan for vulnerabilities.
926
There may be times you want to add an exclusion for a known vulnerability that we are happy to accept
1027
To do this, in the calling repo, add trivy.yaml with this content
1128
```
@@ -22,7 +39,7 @@ vulnerabilities:
2239
```
2340
See https://trivy.dev/docs/latest/configuration/filtering/#trivyignoreyaml for more details
2441

25-
## combine dependabot prs
42+
## Combine Dependabot PRs
2643

2744
This workflow can be called to combine multiple open Dependabot PRs into a single PR.
2845

@@ -68,7 +85,7 @@ jobs:
6885
ignoreLabel: ${{ github.event.inputs.ignoreLabel }}
6986
```
7087
71-
## dependabot auto approve and merge
88+
## Dependabot Auto Approve and Merge
7289
This workflow can be called to automatically approve and merge Dependabot PRs as part of the pull request workflow.
7390
7491
#### Requirements
@@ -91,7 +108,7 @@ jobs:
91108
AUTOMERGE_APP_ID: ${{ secrets.AUTOMERGE_APP_ID }}
92109
AUTOMERGE_PEM: ${{ secrets.AUTOMERGE_PEM }}
93110
```
94-
## pr title check
111+
## PR Title Check
95112
This workflow checks that all pull requests have a title that matches the required format, and comments on the PR with a link to the relevant ticket if a ticket reference is found.
96113

97114
#### Example
@@ -110,7 +127,7 @@ jobs:
110127
uses: NHSDigital/eps-common-workflows/.github/workflows/pr_title_check.yml@f5c8313a10855d0cc911db6a9cd666494c00045a
111128
```
112129

113-
## quality checks
130+
## Quality Checks
114131
This workflow runs common quality checks.
115132
To use this, you must have the following Makefile targets defined
116133
- install
@@ -123,15 +140,15 @@ To use this, you must have the following Makefile targets defined
123140

124141
#### Inputs
125142

126-
- `install_java`: Whether to install java or not
127-
- `run_sonar`: Whether to run sonar checks or not.
143+
- `install_java`: Whether to install Java or not
144+
- `run_sonar`: Whether to run Sonar checks or not.
128145
- `asdfVersion`: Override the version of asdf to install.
129-
- `reinstall_poetry`: If you are using this from a primarily python based project, you should set this to true to force a poetry reinstallation after python is installed
130-
- `run_docker_scan`: whether to run a scan of docker images
131-
- `docker_images`: csv list of docker images to scan. These must match images produced by make docker-build
146+
- `reinstall_poetry`: If you are using this from a primarily Python based project, you should set this to true to force a poetry reinstallation after Python is installed
147+
- `run_docker_scan`: whether to run a scan of Docker images
148+
- `docker_images`: csv list of Docker images to scan. These must match images produced by make docker-build
132149

133150
#### Secret Inputs
134-
- `SONAR_TOKEN`: Token used to authenticate to sonar
151+
- `SONAR_TOKEN`: Token used to authenticate to Sonar
135152

136153
#### Outputs
137154

@@ -157,17 +174,17 @@ jobs:
157174
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
158175
```
159176

160-
## quality checks - dev container version
177+
## Quality Checks - Dev Container Version
161178
This workflow runs common quality checks using a prebuilt devcontainer (https://github.com/NHSDigital/eps-devcontainers).
162179
To use this, you must have overridden any common makefile targets described in https://github.com/NHSDigital/eps-devcontainers?tab=readme-ov-file#common-makefile-targets
163180
#### Inputs
164181

165-
- `run_sonar`: Whether to run sonar checks or not.
166-
- `run_docker_scan`: whether to run a scan of docker images
167-
- `docker_images`: csv list of docker images to scan. These must match images produced by make docker-build
168-
- `runtime_docker_image`: the docker image to run everything on. This should just be the image name and tag pushed to https://github.com/NHSDigital/eps-devcontainers
182+
- `run_sonar`: Whether to run Sonar checks or not.
183+
- `run_docker_scan`: whether to run a scan of Docker images
184+
- `docker_images`: csv list of Docker images to scan. These must match images produced by make docker-build
185+
- `runtime_docker_image`: the Docker image to run everything on. This should just be the image name and tag pushed to https://github.com/NHSDigital/eps-devcontainers
169186
#### Secret Inputs
170-
- `SONAR_TOKEN`: Token used to authenticate to sonar
187+
- `SONAR_TOKEN`: Token used to authenticate to Sonar
171188

172189
#### Outputs
173190

@@ -195,9 +212,48 @@ jobs:
195212
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
196213
```
197214

215+
## Verify Image Digest and Attestation
216+
This workflow resolves an image reference to a pinned digest and verifies GitHub artifact attestation for that image.
217+
218+
#### Inputs
219+
220+
- `runtime_docker_image`: Image reference as `name:tag` (for example `node_24_python_3_12:v1.2.3`) or a fully qualified image reference.
221+
- `registry`: Container registry host. Default: `ghcr.io`
222+
- `namespace`: Image namespace/repository prefix. Default: `nhsdigital/eps-devcontainers`
223+
- `owner`: GitHub owner used by `gh attestation verify --owner`. Default: `NHSDigital`
224+
- `verify_published_from_main_image`: If true, verifies attestations published from `refs/heads/main`. Default: `true`
225+
- `predicate_type`: Attestation predicate type. Default: `https://slsa.dev/provenance/v1`
226+
227+
#### Outputs
228+
229+
- `pinned_image`: Fully-qualified digest-pinned image reference.
230+
- `resolved_digest`: Resolved digest for the supplied image reference.
231+
232+
#### Example
233+
234+
To use this workflow in your repository, call it from another workflow file:
235+
236+
```yaml
237+
name: Verify Devcontainer Image
238+
239+
on:
240+
workflow_dispatch:
241+
242+
jobs:
243+
verify_attestation:
244+
uses: NHSDigital/eps-common-workflows/.github/workflows/verify-attestation.yml@f5c8313a10855d0cc911db6a9cd666494c00045a
245+
with:
246+
runtime_docker_image: node_24_python_3_12:githubactions-v1.2.3
247+
registry: ghcr.io
248+
namespace: nhsdigital/eps-devcontainers
249+
owner: NHSDigital
250+
verify_published_from_main_image: true
251+
predicate_type: https://slsa.dev/provenance/v1
252+
```
253+
198254

199-
## tag release
200-
This workflow uses the semantic-release npm package to generate a new version tag, changelog, and github release for a repo.
255+
## Tag Release
256+
This workflow uses the semantic-release npm package to generate a new version tag, changelog, and GitHub release for a repo.
201257

202258
#### Inputs
203259

@@ -211,7 +267,7 @@ This workflow uses the semantic-release npm package to generate a new version ta
211267
#### Outputs
212268

213269
- `version_tag`: The version tag created by semantic-release.
214-
- `change_set_version`: A timestamped string that con be used for creating changesets.
270+
- `change_set_version`: A timestamped string that can be used for creating changesets.
215271

216272
#### Example
217273

@@ -234,26 +290,27 @@ jobs:
234290
publish_package: false
235291
```
236292

237-
## tag release - devcontainer version
238-
This workflow uses the semantic-release npm package to generate a new version tag, changelog, and github release for a repo.
239-
*The devcontainer MUST have node installed*
293+
## Tag Release - Devcontainer Version
294+
This workflow uses the semantic-release npm package to generate a new version tag, changelog, and GitHub release for a repo.
295+
*The devcontainer MUST have Node installed*
240296
#### Inputs
241297

242298
- `dry_run`: Whether to run in dry_run mode (do not create tags) or not
243299
- `branch_name`: The branch name to base the release on
244-
- `runtime_docker_image`: the docker image to run everything on. This should just be the image name and tag pushed to https://github.com/NHSDigital/eps-devcontainers
300+
- `runtime_docker_image`: the Docker image to run everything on. This should just be the image name and tag pushed to https://github.com/NHSDigital/eps-devcontainers
245301
- `publish_packages`: comma separated list of package folders to publish to an npm registry
246302
- `tagFormat`: Default `v\\${version}`. A template for the version tag.
247303
- `main_branch`: The branch to use for publishing. Defaults to main
248304
- `extra_artifact_name`: optional param to include an extra artifact in the release
249305
- `extra_artifact_id`: optional param of the extra artifact id to include in the release
250306
- `extra_artifact_run_id`: optional param of the run id to download the extra artifact id to include in the release
251307
- `extra_artifact_repository` optional param to indicate which repo the run to download the artifact was from
308+
- `verify_published_from_main_image` indicates if we should verify the image was published from main branch in eps-devcontainers
252309

253310
#### Outputs
254311

255312
- `version_tag`: The version tag created by semantic-release.
256-
- `change_set_version`: A timestamped string that con be used for creating changesets.
313+
- `change_set_version`: A timestamped string that can be used for creating changesets.
257314

258315
#### Example
259316

@@ -278,9 +335,9 @@ jobs:
278335
```
279336

280337

281-
## Secret scanning docker
338+
## Secret Scanning Docker
282339

283-
The secret scanning also has a dockerfile, which can be run against a repo in order to scan it manually (or as part of pre-commit hooks). This can be done like so:
340+
The secret scanning also has a Dockerfile, which can be run against a repo in order to scan it manually (or as part of pre-commit hooks). This can be done like so:
284341
```bash
285342
docker build -f https://raw.githubusercontent.com/NHSDigital/eps-workflow-quality-checks/refs/tags/v3.0.0/dockerfiles/nhsd-git-secrets.dockerfile -t git-secrets .
286343
docker run -v /path/to/repo:/src git-secrets --scan-history .
@@ -302,7 +359,7 @@ In order to enable the pre-commit hook for secret scanning (to prevent developer
302359
}
303360
```
304361

305-
And the this pre-commit hook to the `.pre-commit-config.yaml` file:
362+
And add this pre-commit hook to the `.pre-commit-config.yaml` file:
306363
```yaml
307364
repos:
308365
- repo: local
@@ -317,28 +374,28 @@ repos:
317374
language: system
318375
```
319376

320-
## Run all releases
377+
## Run All Releases
321378

322379
There are some scripts that can be used to trigger releases for all our repos.
323380
It is invoked by running `./scripts/run_all_release.sh`.
324-
This first authenticates to github using github cli tools to get a valid github token.
381+
This first authenticates to GitHub using GitHub CLI tools to get a valid GitHub token.
325382

326383
It then has an array of repos which it loops through asking for confirmation if you want to run deployment for it.
327384

328-
For any that you have answered yes to, it then calls the python script `scripts/trigger_release.py`.
385+
For any that you have answered yes to, it then calls the Python script `scripts/trigger_release.py`.
329386

330-
The python script will trigger the release.yml workflow for that repo and monitor the the run for it.
387+
The Python script will trigger the release.yml workflow for that repo and monitor the run for it.
331388
When it reaches one of the steps release_qa, release_ref, release_int it will approve release to that environment.
332-
Once the run reaches release_prod step, the python script will exit.
333-
The python script will also exit if the github run fails, or is cancelled at any step, or there is an unexpected response from github (eg user does not have permission to approve a deployment).
334-
When the python script finishes, it logs the run url, the tag and summary of what happened.
389+
Once the run reaches release_prod step, the Python script will exit.
390+
The Python script will also exit if the GitHub run fails, or is cancelled at any step, or there is an unexpected response from GitHub (eg user does not have permission to approve a deployment).
391+
When the Python script finishes, it logs the run URL, the tag and summary of what happened.
335392
Python logs go to the console, and to a timestamped file in the logs folder.
336393

337394
When all runs of the python script have finished then the shell script exits showing a summary of failed and successful runs.
338395

339396

340-
If a run fails on a step BEFORE the tag_release step, and the failure is transient (eg quality checks fails installing dependencies due to npm being down) then the whole release workflow can be rerun - either via this script or using the github website.
397+
If a run fails on a step BEFORE the tag_release step, and the failure is transient (eg quality checks fails installing dependencies due to npm being down) then the whole release workflow can be rerun - either via this script or using the GitHub website.
341398

342-
If a run fails on a step AFTER the tag_release step, and the failure is transient (eg regression tests failure) then that failing step can just be re-run manually via the github website.
399+
If a run fails on a step AFTER the tag_release step, and the failure is transient (eg regression tests failure) then that failing step can just be re-run manually via the GitHub website.
343400

344401
If a run fails due to a code or cloudformation/cdk issue, then a new pull request should be created to fix this, merged to main, and a new release triggered.

0 commit comments

Comments
 (0)