Skip to content

Commit

Permalink
Another approach
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Aug 7, 2024
1 parent cea1c4a commit 73dc4f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ jobs:
build.json
.github/workflows/env.hcl
- name: Set output variables
- name: Set output image names
id: bake_metadata
# bake-action metadata output has gotten too big, so we first write it
# to a file. See https://github.com/aiidalab/aiidalab-docker-stack/issues/491
run: |
.github/workflows/extract-image-names.sh | tee -a "${GITHUB_OUTPUT}" | awk -F'=' '{print $2}' | jq
env:
BAKE_METADATA: ${{ steps.build-upload.outputs.metadata }}
cat << EOF
${{ steps.build-upload.outputs.metadata }}
EOF > bake_metadata.json
.github/workflows/extract-image-names.sh bake_metadata.json | tee -a "${GITHUB_OUTPUT}" | tr -d 'images=' | jq
6 changes: 2 additions & 4 deletions .github/workflows/extract-image-names.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ set -euo pipefail
# (e.g. BASE_IMAGE=ghcr.io/aiidalab/base@sha256:8e57a52b...)
# and these are in turn read in the docker-compose.<target>.yml files for tests.

# NOTE: BAKE_METADATA has gotten too large and cannot be passed directly as cmdline argument to avoid
# "Argument list too long" BASH error, see: https://github.com/aiidalab/aiidalab-docker-stack/issues/491
# Therefore we first need to parse the output from `env` command and pass it to jq via piped stdin
images=$(env | grep -E "^BAKE_METADATA=" | tr -d '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')
metadata_file=$1
images=$(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' $metadata_file)
echo "images=$images"

0 comments on commit 73dc4f0

Please sign in to comment.