Skip to content

Commit 88f13d5

Browse files
authored
Chore: [AEA-0000] - correct secret name in update dev container workflow (#105)
## Summary - Routine Change ### Details - correct secret name in update dev container workflow
1 parent 344522b commit 88f13d5

2 files changed

Lines changed: 118 additions & 118 deletions

File tree

Lines changed: 113 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,150 @@
11
name: Update Dev Container Image version
22
on:
3-
workflow_call:
4-
inputs:
5-
base_branch:
6-
required: false
7-
type: string
8-
default: main
9-
secrets:
10-
AUTOMERGE_APP_ID:
11-
required: true
12-
AUTOMERGE_PEM:
13-
required: true
3+
workflow_call:
4+
inputs:
5+
base_branch:
6+
required: false
7+
type: string
8+
default: main
9+
secrets:
10+
CREATE_PULL_REQUEST_APP_ID:
11+
required: true
12+
CREATE_PULL_REQUEST_PEM:
13+
required: true
1414
jobs:
15-
update_devcontainer_version:
16-
runs-on: ubuntu-22.04
17-
permissions:
18-
contents: read
19-
packages: read
20-
pull-requests: write
21-
steps:
22-
- name: Checkout code
23-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
24-
with:
25-
fetch-depth: 0
26-
- name: Load config value
27-
id: load-config
28-
run: >
29-
DEVCONTAINER_IMAGE=$(jq -r '.build.args.IMAGE_NAME'
30-
.devcontainer/devcontainer.json)
15+
update_devcontainer_version:
16+
runs-on: ubuntu-22.04
17+
permissions:
18+
contents: read
19+
packages: read
20+
pull-requests: write
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
24+
with:
25+
fetch-depth: 0
26+
- name: Load config value
27+
id: load-config
28+
run: |
29+
set -euo pipefail
30+
DEVCONTAINER_IMAGE=$(jq -r '.build.args.IMAGE_NAME'
31+
.devcontainer/devcontainer.json)
3132
32-
DEVCONTAINER_VERSION=$(jq -r '.build.args.IMAGE_VERSION'
33-
.devcontainer/devcontainer.json)
33+
DEVCONTAINER_VERSION=$(jq -r '.build.args.IMAGE_VERSION'
34+
.devcontainer/devcontainer.json)
3435
35-
{
36-
echo "DEVCONTAINER_IMAGE=$DEVCONTAINER_IMAGE"
37-
echo "DEVCONTAINER_VERSION=$DEVCONTAINER_VERSION"
38-
} >> "$GITHUB_ENV"
39-
- name: Resolve latest devcontainer image version from GHCR
40-
id: resolve-version
41-
env:
42-
GH_TOKEN: "${{ github.token }}"
43-
run: >
44-
set -euo pipefail
36+
{
37+
echo "DEVCONTAINER_IMAGE=$DEVCONTAINER_IMAGE"
38+
echo "DEVCONTAINER_VERSION=$DEVCONTAINER_VERSION"
39+
} >> "$GITHUB_ENV"
40+
- name: Resolve latest devcontainer image version from GHCR
41+
id: resolve-version
42+
env:
43+
GH_TOKEN: "${{ github.token }}"
44+
run: |
45+
set -euo pipefail
4546
4647
47-
PACKAGE_NAME="eps-devcontainers/${DEVCONTAINER_IMAGE}"
48+
PACKAGE_NAME="eps-devcontainers/${DEVCONTAINER_IMAGE}"
4849
49-
ENCODED_PACKAGE_NAME=$(python3 -c 'import sys, urllib.parse;
50-
print(urllib.parse.quote(sys.argv[1], safe=""))' "$PACKAGE_NAME")
50+
ENCODED_PACKAGE_NAME=$(python3 -c 'import sys, urllib.parse;
51+
print(urllib.parse.quote(sys.argv[1], safe=""))' "$PACKAGE_NAME")
5152
5253
53-
VERSIONS_JSON=$(gh api \
54-
-H "Accept: application/vnd.github+json" \
55-
"/orgs/NHSDigital/packages/container/${ENCODED_PACKAGE_NAME}/versions?per_page=100")
54+
VERSIONS_JSON=$(gh api \
55+
-H "Accept: application/vnd.github+json" \
56+
"/orgs/NHSDigital/packages/container/${ENCODED_PACKAGE_NAME}/versions?per_page=100")
5657
57-
LATEST_VIA_LATEST_TAG=$(jq -r '
58-
[ .[]
59-
| select((.metadata.container.tags // []) | index("latest"))
60-
]
61-
| sort_by(.created_at)
62-
| reverse
63-
| .[0].metadata.container.tags // []
64-
| map(select(test("^v")))
65-
| .[0] // empty
66-
' <<< "$VERSIONS_JSON")
58+
LATEST_VIA_LATEST_TAG=$(jq -r '
59+
[ .[]
60+
| select((.metadata.container.tags // []) | index("latest"))
61+
]
62+
| sort_by(.created_at)
63+
| reverse
64+
| .[0].metadata.container.tags // []
65+
| map(select(test("^v")))
66+
| .[0] // empty
67+
' <<< "$VERSIONS_JSON")
6768
6869
69-
LATEST_V_TAG=$(jq -r '
70-
[ .[]
71-
| {created_at, tags: (.metadata.container.tags // [])}
72-
]
73-
| sort_by(.created_at)
74-
| reverse
75-
| map(.tags[]? | select(test("^v")))
76-
| .[0] // empty
77-
' <<< "$VERSIONS_JSON")
70+
LATEST_V_TAG=$(jq -r '
71+
[ .[]
72+
| {created_at, tags: (.metadata.container.tags // [])}
73+
]
74+
| sort_by(.created_at)
75+
| reverse
76+
| map(.tags[]? | select(test("^v")))
77+
| .[0] // empty
78+
' <<< "$VERSIONS_JSON")
7879
7980
80-
RESOLVED_VERSION="$LATEST_VIA_LATEST_TAG"
81+
RESOLVED_VERSION="$LATEST_VIA_LATEST_TAG"
8182
82-
if [[ -z "$RESOLVED_VERSION" ]]; then
83-
RESOLVED_VERSION="$LATEST_V_TAG"
84-
fi
83+
if [[ -z "$RESOLVED_VERSION" ]]; then
84+
RESOLVED_VERSION="$LATEST_V_TAG"
85+
fi
8586
8687
87-
if [[ -z "$RESOLVED_VERSION" ]]; then
88-
echo "No version tag matching ^v found for package ${PACKAGE_NAME}" >&2
89-
exit 1
90-
fi
88+
if [[ -z "$RESOLVED_VERSION" ]]; then
89+
echo "No version tag matching ^v found for package ${PACKAGE_NAME}" >&2
90+
exit 1
91+
fi
9192
9293
93-
echo "Resolved latest version: ${RESOLVED_VERSION}"
94+
echo "Resolved latest version: ${RESOLVED_VERSION}"
9495
95-
echo "LATEST_DEVCONTAINER_VERSION=${RESOLVED_VERSION}" >>
96-
"$GITHUB_ENV"
96+
echo "LATEST_DEVCONTAINER_VERSION=${RESOLVED_VERSION}" >> "$GITHUB_ENV"
9797
98-
echo "latest_version=${RESOLVED_VERSION}" >> "$GITHUB_OUTPUT"
99-
- name: Update devcontainer version in config
100-
run: >
101-
set -euo pipefail
98+
echo "latest_version=${RESOLVED_VERSION}" >> "$GITHUB_OUTPUT"
99+
- name: Update devcontainer version in config
100+
run: |
101+
set -euo pipefail
102102
103103
104-
TARGET_VERSION='${{ steps.resolve-version.outputs.latest_version }}'
104+
TARGET_VERSION='${{ steps.resolve-version.outputs.latest_version }}'
105105
106-
if [[ "$TARGET_VERSION" == "$DEVCONTAINER_VERSION" ]]; then
107-
echo "IMAGE_VERSION is already up to date (${DEVCONTAINER_VERSION})"
108-
exit 0
109-
fi
106+
if [[ "$TARGET_VERSION" == "$DEVCONTAINER_VERSION" ]]; then
107+
echo "IMAGE_VERSION is already up to date (${DEVCONTAINER_VERSION})"
108+
exit 0
109+
fi
110110
111111
112-
python3 - <<'PY'
112+
python3 - <<'PY'
113113
114-
import json
114+
import json
115115
116-
from pathlib import Path
116+
from pathlib import Path
117117
118118
119-
config_file = Path('.devcontainer/devcontainer.json')
119+
config_file = Path('.devcontainer/devcontainer.json')
120120
121-
config = json.loads(config_file.read_text())
121+
config = json.loads(config_file.read_text())
122122
123-
config['build']['args']['IMAGE_VERSION'] = '${{
124-
steps.resolve-version.outputs.latest_version }}'
123+
config['build']['args']['IMAGE_VERSION'] = '${{
124+
steps.resolve-version.outputs.latest_version }}'
125125
126-
config_file.write_text(json.dumps(config, indent=2) + '\n')
126+
config_file.write_text(json.dumps(config, indent=2) + '\n')
127127
128-
PY
128+
PY
129129
130130
131-
echo "Updated IMAGE_VERSION from ${DEVCONTAINER_VERSION} to
132-
${LATEST_DEVCONTAINER_VERSION}"
133-
- name: Create GitHub App Token
134-
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859
135-
id: generate-token
136-
with:
137-
app-id: "${{ secrets.AUTOMERGE_APP_ID }}"
138-
private-key: "${{ secrets.AUTOMERGE_PEM }}"
139-
- name: Create Pull Request
140-
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
141-
with:
142-
token: "${{ steps.generate-token.outputs.token }}"
143-
commit-message: Update devcontainer image version to ${{ steps.resolve-version.outputs.latest_version }}
144-
title: "Upgrade: [dependabot] - Update devcontainer image version to ${{ steps.resolve-version.outputs.latest_version }}"
145-
body: "This PR updates the devcontainer image version to ${{ steps.resolve-version.outputs.latest_version }}."
146-
add-paths: .devcontainer/devcontainer.json
147-
sign-commits: true
148-
base: "${{ inputs.base_branch }}"
149-
delete-branch: true
150-
branch: update-devcontainer-version
131+
echo "Updated IMAGE_VERSION from ${DEVCONTAINER_VERSION} to
132+
${LATEST_DEVCONTAINER_VERSION}"
133+
- name: Create GitHub App Token
134+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859
135+
id: generate-token
136+
with:
137+
app-id: "${{ secrets.CREATE_PULL_REQUEST_APP_ID }}"
138+
private-key: "${{ secrets.CREATE_PULL_REQUEST_PEM }}"
139+
- name: Create Pull Request
140+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
141+
with:
142+
token: "${{ steps.generate-token.outputs.token }}"
143+
commit-message: Update devcontainer image version to ${{ steps.resolve-version.outputs.latest_version }}
144+
title: "Upgrade: [dependabot] - Update devcontainer image version to ${{ steps.resolve-version.outputs.latest_version }}"
145+
body: "This PR updates the devcontainer image version to ${{ steps.resolve-version.outputs.latest_version }}."
146+
add-paths: .devcontainer/devcontainer.json
147+
sign-commits: true
148+
base: "${{ inputs.base_branch }}"
149+
delete-branch: true
150+
branch: update-devcontainer-version

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,16 @@ This workflow updates `.devcontainer/devcontainer.json` with the latest publishe
257257
#### Requirements
258258

259259
- `.devcontainer/devcontainer.json` must include `build.args.IMAGE_NAME` and `build.args.IMAGE_VERSION`.
260-
- `AUTOMERGE_APP_ID` and `AUTOMERGE_PEM` secrets must be configured so the workflow can create a GitHub App token for PR creation.
260+
- `CREATE_PULL_REQUEST_APP_ID` and `CREATE_PULL_REQUEST_PEM` secrets must be configured so the workflow can create a GitHub App token for PR creation.
261261

262262
#### Inputs
263263

264264
- `base_branch`: Target branch for the pull request. Default: `main`.
265265

266266
#### Secret Inputs
267267

268-
- `AUTOMERGE_APP_ID`: GitHub App ID used to generate an installation token.
269-
- `AUTOMERGE_PEM`: GitHub App private key used to generate an installation token.
268+
- `CREATE_PULL_REQUEST_APP_ID`: GitHub App ID used to generate an installation token.
269+
- `CREATE_PULL_REQUEST_PEM`: GitHub App private key used to generate an installation token.
270270

271271
#### Outputs
272272

@@ -288,8 +288,8 @@ jobs:
288288
with:
289289
base_branch: main
290290
secrets:
291-
AUTOMERGE_APP_ID: ${{ secrets.AUTOMERGE_APP_ID }}
292-
AUTOMERGE_PEM: ${{ secrets.AUTOMERGE_PEM }}
291+
CREATE_PULL_REQUEST_APP_ID: ${{ secrets.CREATE_PULL_REQUEST_APP_ID }}
292+
CREATE_PULL_REQUEST_PEM: ${{ secrets.CREATE_PULL_REQUEST_PEM }}
293293
```
294294

295295
## Tag Release

0 commit comments

Comments
 (0)