Skip to content

Commit 9e045d2

Browse files
authored
Add container image reference to release notes (#1236)
* feat: update release notes to include container image reference Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech> * Address copilot review comments Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech> --------- Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
1 parent f4945c0 commit 9e045d2

1 file changed

Lines changed: 51 additions & 2 deletions

File tree

.github/workflows/after-tag-with-version.yaml

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2022 Google LLC
2-
# Modifications Copyright (C) 2025 OpenInfra Foundation Europe.
2+
# Modifications Copyright (C) 2025-2026 OpenInfra Foundation Europe.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
permissions:
2828
packages: write
29-
contents: read
29+
contents: write
3030
steps:
3131
- name: Checkout
3232
uses: actions/checkout@v4
@@ -73,3 +73,52 @@ jobs:
7373
echo "Tag does not match any known type, skipping."
7474
exit 0
7575
fi
76+
77+
- name: Read image reference from metadata
78+
id: meta
79+
run: |
80+
IMAGE_NAME="${{ steps.extract.outputs.image_name }}"
81+
VERSION="${{ steps.extract.outputs.version }}"
82+
FUNC_DIR="functions/go/${IMAGE_NAME}"
83+
84+
if [[ ! -f "${FUNC_DIR}/metadata.yaml" ]]; then
85+
echo "::error::${FUNC_DIR}/metadata.yaml not found"
86+
exit 1
87+
fi
88+
89+
IMAGE_BASE=$(grep '^image:' "${FUNC_DIR}/metadata.yaml" | awk '{print $2}' | tr -d '"')
90+
if [[ -z "$IMAGE_BASE" ]]; then
91+
echo "::error::No image field in ${FUNC_DIR}/metadata.yaml"
92+
exit 1
93+
fi
94+
95+
echo "image_ref=${IMAGE_BASE}:${VERSION}" >> "$GITHUB_OUTPUT"
96+
97+
- name: Add image reference to release notes
98+
if: steps.meta.outputs.image_ref != ''
99+
env:
100+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
run: |
102+
TAG="${GITHUB_REF#refs/tags/}"
103+
IMAGE_REF="${{ steps.meta.outputs.image_ref }}"
104+
105+
if ! gh release view "$TAG" --repo "${{ github.repository }}" > /dev/null 2>&1; then
106+
echo "No release found for tag $TAG, skipping."
107+
exit 0
108+
fi
109+
110+
CURRENT_BODY=$(gh release view "$TAG" --repo "${{ github.repository }}" --json body -q .body)
111+
112+
if [[ "$CURRENT_BODY" == *"$IMAGE_REF"* ]]; then
113+
echo "Image reference already present in release notes, skipping."
114+
exit 0
115+
fi
116+
117+
NOTES_FILE=$(mktemp)
118+
printf '%s\n\n## Container Image\n\n```\n%s\n```' "$CURRENT_BODY" "$IMAGE_REF" > "$NOTES_FILE"
119+
120+
gh release edit "$TAG" \
121+
--repo "${{ github.repository }}" \
122+
--notes-file "$NOTES_FILE"
123+
124+
rm -f "$NOTES_FILE"

0 commit comments

Comments
 (0)