Skip to content

Commit 013e648

Browse files
authored
fix: Correct script paths and add repo digest script (#8)
* fix: add repo digest script * make script executable * adjust path to script in publish-index-manifest action
1 parent 01e3c0f commit 013e648

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

.scripts/get_repo_digest.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
# The script outputs the image manifest uri with the SHA256 digest, for example:
4+
# oci.stackable.tech/sdp/hello-world@sha256:917f800259ef4915f976e93987b752fd64debf347568610d7f685d20220fc88a
5+
set -euo pipefail
6+
7+
# There is only one input to this script, which contains the entire image
8+
# manifest uri, like: oci.stackable.tech/sdp/hello-world:0.0.1-SNAPSHOT-stackable0.0.0-dev-arm64
9+
IMAGE_MANIFEST_URI="$1"
10+
11+
# Here, we cut off the image manifest tag to get the image repository uri, for
12+
# example: oci.stackable.tech/sdp/hello-world
13+
IMAGE_REPOSITORY_URI="$(echo "$IMAGE_MANIFEST_URI" | cut -d : -f 1)"
14+
15+
IMAGE_REPO_DIGEST=$(
16+
docker inspect "$IMAGE_MANIFEST_URI" --format json | \
17+
jq -r \
18+
--arg IMAGE_REPOSITORY_URI "$IMAGE_REPOSITORY_URI" \
19+
--arg IMAGE_MANIFEST_URI "$IMAGE_MANIFEST_URI" \
20+
'
21+
map(select(.RepoTags[] | contains($IMAGE_MANIFEST_URI)))[0]
22+
| .RepoDigests[]
23+
| select(. | startswith($IMAGE_REPOSITORY_URI))
24+
'
25+
)
26+
27+
# Ensure IMAGE_REPO_DIGEST is not empty
28+
if [[ -z "$IMAGE_REPO_DIGEST" ]]; then
29+
>&2 echo "Repo Digest is empty, but is required for signing"
30+
exit 1
31+
fi
32+
33+
echo "$IMAGE_REPO_DIGEST"

publish-image/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ runs:
8585
docker image push "$IMAGE_MANIFEST_URI"
8686
8787
# Output for the next step
88-
echo "IMAGE_REPO_DIGEST=$($GITHUB_ACTION_PATH/.scripts/get_repo_digest.sh $IMAGE_MANIFEST_URI)" | tee -a "$GITHUB_ENV"
88+
echo "IMAGE_REPO_DIGEST=$($GITHUB_ACTION_PATH/../.scripts/get_repo_digest.sh $IMAGE_MANIFEST_URI)" | tee -a "$GITHUB_ENV"
8989
9090
- name: Sign the container image (${{ env.IMAGE_REPO_DIGEST }})
9191
shell: bash

publish-index-manifest/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ runs:
9797
set -euo pipefail
9898
9999
# Get the image index manifest digest
100-
DIGEST=$($GITHUB_ACTION_PATH/.scripts/get_manifest_digest.sh "$IMAGE_INDEX_URI")
100+
DIGEST=$($GITHUB_ACTION_PATH/../.scripts/get_manifest_digest.sh "$IMAGE_INDEX_URI")
101101
102102
# Construct the image repo digest, which for example contains:
103103
# docker.stackable.tech/stackable/kafka@sha256:91...

0 commit comments

Comments
 (0)