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