Skip to content

build: Add CI check that image-data and workflow lists are in sync #1

build: Add CI check that image-data and workflow lists are in sync

build: Add CI check that image-data and workflow lists are in sync #1

# Require that images-data.json and the list of images in
# push-docker-images.yaml are kept in sync.
name: Check that image lists are in sync
on:
# To make this a required check, has to run even if no relevant
# config changes. So can't filter on paths here.
pull_request:
defaults:
run:
shell: bash # making this explicit opts into -e -o pipefail
jobs:
check-image-list-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Detect and report
run: |
python3.12 -m venv --upgrade-deps ./deps-venv
pip=./deps-venv/bin/pip
$pip install --quiet jq yq
jq=./deps-venv/bin/yq
yq=./deps-venv/bin/yq
json_src=images-data.json
workflow_src=.github/workflows/push-docker-images.yml
cat json_src \
| jq '.[].name' -r
| sort \
> names-in-json.lst
cat "$workflow_src" \
| yq '.on.workflow_dispatch.inputs.image_to_build.options[]' -r \
| sort \
> options-in-workflow.lst
set +e
diff_out=$(diff -u0 names-in-json.lst options-in-workflow.lst)
diff_exit=$?
set -e
echo
echo
case $diff_exit in
0)
echo "Image lists match" | tee -a "$GITHUB_STEP_SUMMARY"
exit 0
;;
1)
tee -a "$GITHUB_STEP_SUMMARY" <<MESSAGE
Mismatch in image name lists between `${json_src}` and `${workflow_src}`:
```
$diff_out
```
MESSAGE
exit 1
;;
*)
tee -a "$GITHUB_STEP_SUMMARY" <<MESSAGE
Error computing diff:
```
$diff_out
```
Exit code: $diff_exit
MESSAGE
;;
esac