Skip to content

Commit e1467ed

Browse files
agoscinskiunkcpz
andauthored
DevOps: Fix json query in reading the docker names to filter out fields not starting with aiida (aiidateam#6573)
With the version update of bake-action the `BAKE_METADATA` a field with warning information (buildx.build.warnings) was added that does not contain the key `image.name` so the json query failed. With this commit another json query was added that filters out every field name that does not start with "aiida", so the field with warning information is filtered out. Co-authored-by: Jusong Yu <[email protected]>
1 parent 332a4a9 commit e1467ed

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

.github/workflows/extract-docker-image-names.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,35 @@ set -euo pipefail
99
# The input to this script is a JSON string passed via BAKE_METADATA env variable
1010
# Here's example input (trimmed to relevant bits):
1111
# BAKE_METADATA: {
12-
# "base": {
12+
# "aiida-core-base": {
13+
# # ...
1314
# "containerimage.descriptor": {
1415
# "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
1516
# "digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d",
1617
# "size": 6170,
1718
# },
1819
# "containerimage.digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d",
19-
# "image.name": "ghcr.io/aiidalab/base"
20-
# },
21-
# "aiida-core-base": {
2220
# "image.name": "ghcr.io/aiidateam/aiida-core-base"
23-
# "containerimage.digest": "sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26",
24-
# "...": ""
25-
# }
26-
# "aiida-core-with-services": {
27-
# "image.name": "ghcr.io/aiidateam/aiida-core-with-services"
28-
# "containerimage.digest": "sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48",
29-
# "...": ""
30-
# }
21+
# },
3122
# "aiida-core-dev": {
32-
# "image.name": "ghcr.io/aiidateam/aiida-core-with-services"
3323
# "containerimage.digest": "sha256:4d9be090da287fcdf2d4658bb82f78bad791ccd15dac9af594fb8306abe47e97",
24+
# "...": ...
25+
# "image.name": "ghcr.io/aiidateam/aiida-core-dev"
26+
# },
27+
# "aiida-core-with-services": {
3428
# "...": ""
35-
# }
29+
# "containerimage.digest": "sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48",
30+
# "image.name": "ghcr.io/aiidateam/aiida-core-with-services"
31+
# },
32+
# "some-other-key": ...
3633
# }
3734
#
3835
# Example output (real output is on one line):
3936
#
4037
# images={
41-
# "AIIDA_CORE_BASE_IMAGE": "ghcr.io/aiidateam/aiida-core-base@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d",
42-
# "AIIDA_CORE_WITH_SERVICES_IMAGE": "ghcr.io/aiidateam/aiida-core-with-services@sha256:6753a809b5b2675bf4c22408e07c1df155907a465b33c369ef93ebcb1c4fec26",
43-
# "AIIDA_CORE_DEV_IMAGE": "ghcr.io/aiidateam/aiida-core-dev@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48",
38+
# "AIIDA_CORE_BASE_IMAGE": "ghcr.io/aiidateam/aiida-core-base@sha256:4c402a8bfd635650ad691674f8f29e7ddec5fa656fb425452067950415ee447f",
39+
# "AIIDA_CORE_DEV_IMAGE": "ghcr.io/aiidateam/aiida-core-dev@sha256:f94c06e47f801e751f9829010b31532039b210aad2649d43205e16c08371b2ed",
40+
# "AIIDA_CORE_WITH_SERVICES_IMAGE": "ghcr.io/aiidateam/aiida-core-with-services@sha256:bd8272f2a331af7eac3e83c44cc16d23b2e5f601a20ab4a865402659b758515e"
4441
# }
4542
#
4643
# This json output is later turned to environment variables using fromJson() GHA builtin
@@ -52,5 +49,7 @@ if [[ -z ${BAKE_METADATA-} ]];then
5249
exit 1
5350
fi
5451

55-
images=$(echo "${BAKE_METADATA}" | jq -c '. as $base |[to_entries[] |{"key": (.key|ascii_upcase|sub("-"; "_"; "g") + "_IMAGE"), "value": [(.value."image.name"|split(",")[0]),.value."containerimage.digest"]|join("@")}] |from_entries')
52+
images=$(echo "${BAKE_METADATA}" |
53+
jq -c 'to_entries | map(select(.key | startswith("aiida"))) | from_entries' | # filters out every key that does not start with aiida
54+
jq -c '. as $base |[to_entries[] |{"key": (.key|ascii_upcase|sub("-"; "_"; "g") + "_IMAGE"), "value": [(.value."image.name"|split(",")[0]),.value."containerimage.digest"]|join("@")}] |from_entries')
5655
echo "images=$images"

0 commit comments

Comments
 (0)