Skip to content

Commit

Permalink
Fix image name replacement in builder workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Geczy committed Dec 26, 2023
1 parent 134004c commit 53a5106
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v4

# Step 1: Fetch current image manifests
- name: Fetch current manifests
run: |
for IMAGE in $IMAGES; do
IMAGE_NAME=$(echo "$IMAGE" | sed 's/_/-/g') # Replace underscores with hyphens for the actual image names
IMAGE_NAME=$(echo "$IMAGE" | sed 's/_/-/g')
MANIFEST=$(curl -s -H "Accept: application/vnd.oci.image.index.v1+json" -H "Authorization: Bearer ${{ secrets.GHA_READ_PKG }}" "https://ghcr.io/v2/dotabod/$IMAGE_NAME/manifests/v2.1")
echo "OLD_${IMAGE^^}_MANIFEST=$MANIFEST" >> $GITHUB_ENV
done
Expand All @@ -42,30 +41,30 @@ jobs:
set: |
*.platform=linux/arm64
# Step 2: Fetch new manifests and compare
- name: Check for updated images
id: check_updates
run: |
UPDATED_IMAGES=""
for IMAGE in $IMAGES; do
IMAGE_NAME=$(echo "$IMAGE" | sed 's/_/-/g') # Replace underscores with hyphens for the actual image names
IMAGE_NAME=$(echo "$IMAGE" | sed 's/_/-/g')
NEW_MANIFEST=$(curl -H "Accept: application/vnd.oci.image.index.v1+json" -H "Authorization: Bearer ${{ secrets.GHA_READ_PKG }}" "https://ghcr.io/v2/dotabod/$IMAGE_NAME/manifests/v2.1")
OLD_MANIFEST_VAR="OLD_${IMAGE^^}_MANIFEST"
# Compare manifests (e.g., using digests or other relevant data)
# Echo the new_manifest for debug pruposes to the github env for each image
# Echo the new_manifest for debug purposes to the github env for each image
echo "NEW_${IMAGE^^}_MANIFEST=$NEW_MANIFEST" >> $GITHUB_ENV
if [ "$NEW_MANIFEST" != "${!OLD_MANIFEST_VAR}" ]; then
# Trim both new and old manifests from whitespace
NEW_MANIFEST=$(echo "$NEW_MANIFEST" | tr -d '[:space:]' | base64)
OLD_MANIFEST=$(echo "${!OLD_MANIFEST_VAR}" | tr -d '[:space:]' | base64)
# Compare the new and old manifests to see if they don't equal
if [ "$NEW_MANIFEST" != "$OLD_MANIFEST" ]; then
UPDATED_IMAGES+="$IMAGE "
fi
done
echo "UPDATED_IMAGES=$UPDATED_IMAGES" >> $GITHUB_ENV
# Step 3: Conditional notification
- name: Notify on updated images
if: env.UPDATED_IMAGES != ''
run: |
for IMAGE in $UPDATED_IMAGES; do
# Map package name to UUID
case $IMAGE in
"dota") UUID="esgckgc" ;;
"twitch_events") UUID="aopskdk" ;;
Expand Down

0 comments on commit 53a5106

Please sign in to comment.