|
1 | 1 | # Copyright 2022 Google LLC |
2 | | -# Modifications Copyright (C) 2025 OpenInfra Foundation Europe. |
| 2 | +# Modifications Copyright (C) 2025-2026 OpenInfra Foundation Europe. |
3 | 3 | # |
4 | 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | # you may not use this file except in compliance with the License. |
|
26 | 26 | runs-on: ubuntu-latest |
27 | 27 | permissions: |
28 | 28 | packages: write |
29 | | - contents: read |
| 29 | + contents: write |
30 | 30 | steps: |
31 | 31 | - name: Checkout |
32 | 32 | uses: actions/checkout@v4 |
|
73 | 73 | echo "Tag does not match any known type, skipping." |
74 | 74 | exit 0 |
75 | 75 | 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