Skip to content

Commit 51bc648

Browse files
authored
Chore: [AEA-6424] - use new common workflows (#510)
## Summary - Routine Change ### Details - move to latest qc - remove all trivy files - add CODEOWNERS to restrict updates to workflows - use least permissions on all workflows - add --ignore-scripts true to npm install
1 parent 55234dd commit 51bc648

18 files changed

Lines changed: 127 additions & 152 deletions

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"args": {
77
"DOCKER_GID": "${env:DOCKER_GID:}",
88
"IMAGE_NAME": "node_24_python_3_14",
9-
"IMAGE_VERSION": "v1.2.0",
9+
"IMAGE_VERSION": "v1.4.4",
1010
"USER_UID": "${localEnv:USER_ID:}",
1111
"USER_GID": "${localEnv:GROUP_ID:}"
1212
}

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# restrict access to approving workflow changes
2+
.github/workflows/ @NHSDigital/eps-admins

.github/actions/sync_documents/action.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ runs:
6464
shell: bash
6565
run: |
6666
printf "\n"
67-
echo "Comparing local files with s3://${{ steps.find-destination-bucket.outputs.BUCKET_NAME }}..."
68-
DIFFS=$(aws s3 sync ./s3-content s3://${{ steps.find-destination-bucket.outputs.BUCKET_NAME }} --dryrun)
67+
echo "Comparing local files with s3://${BUCKET_NAME}..."
68+
DIFFS=$(aws s3 sync ./s3-content "s3://${BUCKET_NAME}" --dryrun)
6969
7070
if [ -z "$DIFFS" ]; then
7171
echo -e "\033[0;32m✔ NO DISCREPANCIES FOUND.\033[0m"
@@ -76,9 +76,12 @@ runs:
7676
echo "--------------------------------------------------\033[0m"
7777
7878
CLEAN_DIFFS="${DIFFS//$'\n'/'%0A'}"
79-
echo "::warning title=Discrepancy Found in ${{ inputs.TARGET_ENVIRONMENT }}::$CLEAN_DIFFS"
79+
echo "::warning title=Discrepancy Found in ${TARGET_ENVIRONMENT}::$CLEAN_DIFFS"
8080
fi
8181
printf "\n"
82+
env:
83+
TARGET_ENVIRONMENT: ${{ inputs.TARGET_ENVIRONMENT }}
84+
BUCKET_NAME: ${{ steps.find-destination-bucket.outputs.BUCKET_NAME }}
8285

8386
- name: Clear Target Environment
8487
shell: bash

.github/workflows/cdk_package_code.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
pinned_image:
1616
type: string
1717
required: true
18-
18+
permissions: {}
1919
jobs:
2020
package_code:
2121
runs-on: ubuntu-22.04
@@ -36,7 +36,7 @@ jobs:
3636
- name: Checkout code
3737
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
3838
with:
39-
ref: ${{ env.BRANCH_NAME }}
39+
persist-credentials: false
4040

4141
- name: Setting up .npmrc
4242
env:
@@ -102,7 +102,7 @@ jobs:
102102
cdk.json \
103103
.dependencies
104104
105-
- uses: actions/upload-artifact@v7
105+
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
106106
name: upload build artifact
107107
with:
108108
name: build_artifact

.github/workflows/ci.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@ on:
44
push:
55
branches: [main]
66

7-
env:
8-
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}
7+
permissions: {}
98

109
jobs:
1110
get_config_values:
1211
uses: NHSDigital/eps-common-workflows/.github/workflows/get-repo-config.yml@e798d5aee897de6f7dc387dd5623fcd9ba4c8929
12+
permissions:
13+
attestations: read
14+
contents: read
15+
packages: read
1316
with:
1417
verify_published_from_main_image: true
1518

1619
quality_checks:
17-
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@5ac2707dd9cd60ad127275179495b9c890d74711
20+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@e798d5aee897de6f7dc387dd5623fcd9ba4c8929
1821
needs: [get_config_values]
22+
permissions:
23+
contents: read
24+
id-token: write
25+
packages: read
1926
with:
2027
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
2128
secrets:
@@ -27,6 +34,7 @@ jobs:
2734
permissions:
2835
id-token: write
2936
contents: write
37+
packages: write
3038
with:
3139
dry_run: true
3240
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
@@ -36,6 +44,10 @@ jobs:
3644
package_code:
3745
needs: [tag_release, get_config_values]
3846
uses: ./.github/workflows/cdk_package_code.yml
47+
permissions:
48+
contents: read
49+
id-token: write
50+
packages: read
3951
with:
4052
STACK_NAME: epsam
4153
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
@@ -45,6 +57,9 @@ jobs:
4557
release_dev:
4658
needs: [tag_release, package_code, get_config_values]
4759
uses: ./.github/workflows/release_all_stacks.yml
60+
permissions:
61+
contents: write
62+
id-token: write
4863
with:
4964
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
5065
STACK_NAME: epsam
@@ -72,6 +87,9 @@ jobs:
7287
release_qa:
7388
needs: [tag_release, package_code, release_dev, get_config_values]
7489
uses: ./.github/workflows/release_all_stacks.yml
90+
permissions:
91+
contents: write
92+
id-token: write
7593
with:
7694
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
7795
STACK_NAME: epsam

.github/workflows/create_release_notes.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.github/workflows/delete_old_cloudformation_stacks.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
name: 'Delete old cloudformation stacks'
22

3-
# Controls when the action will run - in this case triggered manually
43
on:
54
workflow_dispatch:
65
schedule:
76
- cron: "0 2,14 * * *"
87
push:
98
branches: [main]
109

11-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
10+
permissions: {}
1211
jobs:
13-
# This workflow contains a single job called "combine-prs"
1412
delete-old-cloudformation-stacks:
15-
# The type of runner that the job will run on
1613
runs-on: ubuntu-22.04
1714
permissions:
1815
id-token: write
1916
contents: read
2017

21-
# Steps represent a sequence of tasks that will be executed as part of the job
2218
steps:
2319
- name: Checkout local github scripts
2420
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
2521
with:
26-
ref: ${{ env.BRANCH_NAME }}
22+
persist-credentials: false
2723
sparse-checkout: |
2824
.github/scripts
2925

.github/workflows/pull_request.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ on:
44
pull_request:
55
branches: [main]
66

7-
env:
8-
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
7+
permissions: {}
98

109
jobs:
1110
get_config_values:
1211
uses: NHSDigital/eps-common-workflows/.github/workflows/get-repo-config.yml@e798d5aee897de6f7dc387dd5623fcd9ba4c8929
12+
permissions:
13+
attestations: read
14+
contents: read
15+
packages: read
1316
with:
1417
verify_published_from_main_image: false
1518

@@ -21,16 +24,20 @@ jobs:
2124
- name: Checkout code
2225
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
2326
with:
24-
ref: ${{ env.BRANCH_NAME }}
27+
persist-credentials: false
2528
fetch-depth: 0
2629
- name: Get Commit message
2730
id: commit_message
2831
run: |
2932
echo "commit_message=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
3033
3134
quality_checks:
32-
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@5ac2707dd9cd60ad127275179495b9c890d74711
35+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@e798d5aee897de6f7dc387dd5623fcd9ba4c8929
3336
needs: [get_config_values, get_commit_message]
37+
permissions:
38+
contents: read
39+
id-token: write
40+
packages: read
3441
if: ${{ ! contains(needs.get_commit_message.outputs.commit_message, '#skip-qc') }}
3542
with:
3643
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
@@ -103,12 +110,17 @@ jobs:
103110
dependabot-auto-approve-and-merge:
104111
needs: quality_gate
105112
uses: NHSDigital/eps-common-workflows/.github/workflows/dependabot-auto-approve-and-merge.yml@e798d5aee897de6f7dc387dd5623fcd9ba4c8929
113+
permissions:
114+
contents: write
115+
pull-requests: write
106116
secrets:
107117
AUTOMERGE_APP_ID: ${{ secrets.AUTOMERGE_APP_ID }}
108118
AUTOMERGE_PEM: ${{ secrets.AUTOMERGE_PEM }}
109119

110120
pr_title_format_check:
111121
uses: NHSDigital/eps-common-workflows/.github/workflows/pr_title_check.yml@e798d5aee897de6f7dc387dd5623fcd9ba4c8929
122+
permissions:
123+
pull-requests: write
112124

113125
get_issue_number:
114126
runs-on: ubuntu-22.04
@@ -143,6 +155,10 @@ jobs:
143155
! contains(needs.*.result, 'failure') &&
144156
! contains(needs.*.result, 'cancelled')
145157
uses: ./.github/workflows/cdk_package_code.yml
158+
permissions:
159+
contents: read
160+
id-token: write
161+
packages: read
146162
with:
147163
STACK_NAME: epsam-pr-${{needs.get_issue_number.outputs.issue_number}}
148164
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
@@ -156,6 +172,9 @@ jobs:
156172
! contains(needs.*.result, 'failure') &&
157173
! contains(needs.*.result, 'cancelled')
158174
uses: ./.github/workflows/release_all_stacks.yml
175+
permissions:
176+
contents: write
177+
id-token: write
159178
with:
160179
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
161180
STACK_NAME: epsam-pr-${{needs.get_issue_number.outputs.issue_number}}

0 commit comments

Comments
 (0)