Skip to content

Commit

Permalink
Add registry-path and registry-paths outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
p5 committed Jul 10, 2024
1 parent 741a729 commit f7e522b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Read Outputs
run: |
echo "Digest: ${{ steps.push.outputs.digest }}"
echo "Registry Path": ${{ steps.push.outputs.registry-path }}
echo "Registry Paths": ${{ steps.push.outputs.registry-paths }}
- name: Inspect Image Manifest
env:
MANIFEST_TAG: ${{ github.sha }}-${{ github.run_number }}
Expand Down Expand Up @@ -84,6 +90,12 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
compression-formats: gzip zstd:chunked

- name: Read Outputs
run: |
echo "Digest: ${{ steps.push.outputs.digest }}"
echo "Registry Path": ${{ steps.push.outputs.registry-path }}
echo "Registry Paths": ${{ steps.push.outputs.registry-paths }}
- name: Inspect Image Manifest
env:
MANIFEST_TAG: ${{ github.sha }}-${{ github.run_number }}
Expand Down
13 changes: 11 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ inputs:
outputs:
registry-path:
description: 'The first registry path to which the tag(s) were pushed.'
value: ""
value: ${{ steps.set-outputs.outputs.REGISTRY_PATH }}
registry-paths:
description: 'A JSON array of registry paths to which the tag(s) were pushed.'
value: ""
value: ${{ steps.set-outputs.outputs.REGISTRY_PATHS }}
digest:
description: 'The digest of the pushed image. If pushing multiple compression formats, this will be the digest of the manifest.'
value: ${{ steps.set-outputs.outputs.DIGEST }}
Expand Down Expand Up @@ -92,6 +92,8 @@ runs:
done
DIGEST=$(skopeo inspect docker://${REGISTRY}/${IMAGE}:${manifest_tags[0]} | jq -r .Digest)
echo "DIGEST=${DIGEST}" >> $GITHUB_ENV
echo "REGISTRY_PATH=${REGISTRY}/${IMAGE}:${manifest_tags[0]}" >> $GITHUB_ENV
echo "REGISTRY_PATHS=$(echo "${REGISTRY}/${IMAGE}:${manifest_tags[@]}" | tr -d '\n' | jq -R -s -c 'split(" ")')" >> $GITHUB_ENV
- name: Tag Compressed Images (Multiple)
if: steps.metadata.outputs.COMPRESSION_FORMAT_COUNT > 1
Expand Down Expand Up @@ -212,17 +214,24 @@ runs:
run: |
IFS=' ' read -r -a manifest_names_array <<< "${MANIFEST_NAMES}"
manifest_digests=()
registry_paths=()
for manifest_name in "${manifest_names_array[@]}"; do
echo "Pushing manifest ${manifest_name}..."
${GITHUB_ACTION_PATH}/helpers/retry.sh ${RETRIES} podman manifest push --all=false --format="${IMAGE_FORMAT}" ${manifest_name}
manifest_digests+=($(skopeo inspect docker://${manifest_name} --format '{{.Digest}}'))
registry_paths+=("${manifest_name}")
done
registry_paths_str=$(IFS=' '; echo "${registry_paths[*]}")
echo "REGISTRY_PATHS=$(echo "${manifests[@]}" | tr -d '\n' | jq -R -s -c 'split(" ")' >> $GITHUB_ENV
echo "DIGEST=${manifest_digests[0]}" >> $GITHUB_ENV
echo "REGISTRY_PATH=${registry_paths[0]}" >> $GITHUB_ENV
- name: Set Outputs
id: set-outputs
shell: bash
run: |
echo "DIGEST=${DIGEST}" >> $GITHUB_OUTPUT
echo "REGISTRY_PATH=${REGISTRY_PATH}" >> $GITHUB_OUTPUT
echo "REGISTRY_PATHS=${REGISTRY_PATHS}" >> $GGITHUB_OUTPUT

0 comments on commit f7e522b

Please sign in to comment.