Skip to content

Commit d4f6bd0

Browse files
committed
Update readme as dedicated workflow
1 parent fa2b15d commit d4f6bd0

2 files changed

Lines changed: 84 additions & 42 deletions

File tree

.github/workflows/sync-base-images.yml

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -126,45 +126,6 @@ jobs:
126126
update-readme:
127127
name: Update README with image list
128128
needs: [prepare, manifest]
129-
runs-on: ubuntu-latest
130-
permissions:
131-
contents: write
132-
steps:
133-
- name: Checkout repository
134-
uses: actions/checkout@v4
135-
136-
- name: Install yq
137-
run: |
138-
sudo wget -qO /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64"
139-
sudo chmod +x /usr/local/bin/yq
140-
141-
- name: Generate images table
142-
id: table
143-
run: |
144-
echo "| Image | Architectures |" > table.md
145-
echo "|-------|---------------|" >> table.md
146-
for image in $(yq -r '.images | keys | .[]' config/images.yaml | sort); do
147-
arches=$(yq -r ".images.${image} | keys | .[]" config/images.yaml | sort | paste -sd ', ' -)
148-
echo "| \`${image}\` | ${arches} |" >> table.md
149-
done
150-
151-
- name: Update README
152-
run: |
153-
awk '
154-
/<!-- REGISTRY_IMAGES -->/ { print; while ((getline line < "table.md") > 0) print line; close("table.md"); skip=1; next }
155-
skip && /<!-- \/REGISTRY_IMAGES -->/ { print; skip=0; next }
156-
skip { next }
157-
{ print }
158-
' README.md > README.new && mv README.new README.md
159-
160-
- name: Commit and push if changed
161-
run: |
162-
git config user.name "github-actions[bot]"
163-
git config user.email "github-actions[bot]@users.noreply.github.com"
164-
git add README.md
165-
if git diff --staged --quiet; then
166-
echo "No README changes"
167-
else
168-
git commit -m "chore: update README with images in registry"
169-
git push
170-
fi
129+
uses: ./.github/workflows/update-readme.yml
130+
with:
131+
registry: ${{ env.REGISTRY }}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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

Comments
 (0)