Skip to content

Commit c2fc348

Browse files
committed
feat(ci): 🎉 add workflow to check for missing container images
1 parent 124c850 commit c2fc348

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Check Missing Container Images
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 6 * * *'
7+
8+
jobs:
9+
check-and-build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
fetch-tags: true
17+
18+
- name: List version tags
19+
id: list_tags
20+
run: |
21+
{
22+
tags=$(git tag | grep '^v' | sort -r)
23+
echo "tags<<EOF"
24+
echo "$tags"
25+
echo "EOF"
26+
} >> "$GITHUB_OUTPUT"
27+
28+
- name: Check GHCR for existing images
29+
id: check_images
30+
run: |
31+
missing_tags=()
32+
# Fetch existing image tags from GHCR using GITHUB_TOKEN for auth
33+
ghcr_tags=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
34+
https://ghcr.io/v2/ophiosdev/codex-cli/tags/list | jq -r '.tags[]')
35+
echo "Existing GHCR tags: $ghcr_tags"
36+
37+
while IFS= read -r tag; do
38+
if ! grep -q "^${tag}$" <<< "$ghcr_tags"; then
39+
echo "Image missing for $tag"
40+
missing_tags+=("$tag")
41+
fi
42+
done <<< "${{ steps.list_tags.outputs.tags }}"
43+
44+
{
45+
printf "%s\n" "${missing_tags[@]}"
46+
echo "missing_tags<<EOF"
47+
printf "%s\n" "${missing_tags[@]}"
48+
echo "EOF"
49+
} >> "$GITHUB_OUTPUT"
50+
51+
- name: Generate GitHub App token
52+
id: app_token
53+
uses: actions/create-github-app-token@v2
54+
with:
55+
app-id: ${{ secrets.WORKFLOW_APP_ID }}
56+
private-key: ${{ secrets.WORKFLOW_APP_PRIVATE_KEY }}
57+
58+
- name: Trigger build-and-deploy for missing tags
59+
if: steps.check_images.outputs.missing_tags != ''
60+
env:
61+
GH_TOKEN: ${{ steps.app_token.outputs.token }}
62+
run: |
63+
while read -r tag; do
64+
echo "Triggering build-and-deploy for $tag"
65+
gh workflow run build-and-deploy.yml --ref "$tag"
66+
done <<< "${{ steps.check_images.outputs.missing_tags }}"

0 commit comments

Comments
 (0)