Skip to content

Commit ce4f9a0

Browse files
committed
chore: create workflow for tagging old images
1 parent 7241709 commit ce4f9a0

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Tag Deprecated Docker Images
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- tag-deprecated-images
8+
9+
jobs:
10+
tag-images:
11+
name: Tag Older Images
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Authenticate to Google Cloud
15+
id: auth
16+
uses: google-github-actions/auth@v3
17+
with:
18+
credentials_json: ${{ secrets.CLOUD_SPANNER_PG_ADAPTER_SERVICE_ACCOUNT }}
19+
20+
- name: Set up Cloud SDK
21+
uses: google-github-actions/setup-gcloud@v3
22+
23+
- name: Tag non-latest images with no-new-use-public-image
24+
run: |
25+
set -euo pipefail
26+
for repo in pgadapter pgadapter-distroless pgadapter-emulator; do
27+
echo "=========================================="
28+
echo "Processing repository: $repo"
29+
echo "=========================================="
30+
gcloud artifacts docker images list us-docker.pkg.dev/cloud-spanner-pg-adapter/gcr.io/$repo \
31+
--include-tags \
32+
--format=json | jq -r '
33+
.[]
34+
| select((.tags | index("latest") | not) and
35+
(.tags | any(startswith("no-new-use-public-image-") or
36+
startswith("deprecated-public-image-") or
37+
startswith("update-available-")) | not))
38+
| .version
39+
' | while read -r version; do
40+
if [ -n "$version" ]; then
41+
digest="${version#sha256:}"
42+
short_digest="${digest:0:12}"
43+
echo "Tagging $repo@$version with no-new-use-public-image-$short_digest"
44+
gcloud artifacts docker tags add \
45+
us-docker.pkg.dev/cloud-spanner-pg-adapter/gcr.io/$repo@$version \
46+
us-docker.pkg.dev/cloud-spanner-pg-adapter/gcr.io/$repo:no-new-use-public-image-$short_digest
47+
fi
48+
done
49+
done
50+
echo "Done! All non-latest images and manifests have been tagged."

0 commit comments

Comments
 (0)