|
| 1 | +# Update README with image list from config/images.yaml. |
| 2 | +# Run standalone: Actions → Update README → Run workflow. |
| 3 | +# Also used by the sync workflow after manifest. |
| 4 | +name: Update README |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + registry: |
| 10 | + description: 'Container registry (e.g. ghcr.io)' |
| 11 | + required: false |
| 12 | + default: 'ghcr.io' |
| 13 | + type: string |
| 14 | + workflow_call: |
| 15 | + inputs: |
| 16 | + registry: |
| 17 | + description: 'Container registry (e.g. ghcr.io)' |
| 18 | + required: false |
| 19 | + default: 'ghcr.io' |
| 20 | + type: string |
| 21 | + |
| 22 | +jobs: |
| 23 | + update-readme: |
| 24 | + name: Update README with image list |
| 25 | + runs-on: ubuntu-latest |
| 26 | + permissions: |
| 27 | + contents: write |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Install yq |
| 33 | + run: | |
| 34 | + sudo wget -qO /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64" |
| 35 | + sudo chmod +x /usr/local/bin/yq |
| 36 | +
|
| 37 | + - name: Generate images table |
| 38 | + id: table |
| 39 | + env: |
| 40 | + REGISTRY: ${{ inputs.registry }} |
| 41 | + REPO: ${{ github.repository }} |
| 42 | + run: | |
| 43 | + echo "| Image | Architectures |" > table.md |
| 44 | + echo "|-------|---------------|" >> table.md |
| 45 | + for image in $(yq -r '.images | keys | .[]' config/images.yaml | sort); do |
| 46 | + arches=$(yq -r ".images.${image} | keys | .[]" config/images.yaml | sort | paste -sd ', ' -) |
| 47 | + ref="${REGISTRY}/${REPO}/${image}:latest" |
| 48 | + url="https://${ref}" |
| 49 | + echo "| [\`${ref}\`](${url}) | ${arches} |" >> table.md |
| 50 | + done |
| 51 | + echo "" >> table.md |
| 52 | + echo "### Copy pull reference" >> table.md |
| 53 | + echo "" >> table.md |
| 54 | + for image in $(yq -r '.images | keys | .[]' config/images.yaml | sort); do |
| 55 | + ref="${REGISTRY}/${REPO}/${image}:latest" |
| 56 | + echo "\`\`\`" >> table.md |
| 57 | + echo "$ref" >> table.md |
| 58 | + echo "\`\`\`" >> table.md |
| 59 | + echo "" >> table.md |
| 60 | + done |
| 61 | +
|
| 62 | + - name: Update README |
| 63 | + run: | |
| 64 | + awk ' |
| 65 | + /<!-- REGISTRY_IMAGES -->/ { print; while ((getline line < "table.md") > 0) print line; close("table.md"); skip=1; next } |
| 66 | + skip && /<!-- \/REGISTRY_IMAGES -->/ { print; skip=0; next } |
| 67 | + skip { next } |
| 68 | + { print } |
| 69 | + ' README.md > README.new && mv README.new README.md |
| 70 | +
|
| 71 | + - name: Commit and push if changed |
| 72 | + run: | |
| 73 | + git config user.name "github-actions[bot]" |
| 74 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 75 | + git add README.md |
| 76 | + if git diff --staged --quiet; then |
| 77 | + echo "No README changes" |
| 78 | + else |
| 79 | + git commit -m "chore: update README with images in registry" |
| 80 | + git push |
| 81 | + fi |
0 commit comments