Skip to content

Commit 94ed0f7

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

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
for repo in pgadapter pgadapter-distroless pgadapter-emulator; do
26+
echo "=========================================="
27+
echo "Processing repository: $repo"
28+
echo "=========================================="
29+
gcloud artifacts docker images list us-docker.pkg.dev/cloud-spanner-pg-adapter/gcr.io/$repo \
30+
--include-tags \
31+
--format=json | jq -r '
32+
.[]
33+
| select((.tags | index("latest") | not) and
34+
(.tags | any(startswith("no-new-use-public-image-") or
35+
startswith("deprecated-public-image-") or
36+
startswith("update-available-")) | not))
37+
| .version
38+
' | while read -r version; do
39+
if [ -n "$version" ]; then
40+
digest="${version#sha256:}"
41+
short_digest="${digest:0:12}"
42+
echo "Tagging $repo@$version with no-new-use-public-image-$short_digest"
43+
gcloud artifacts docker tags add \
44+
us-docker.pkg.dev/cloud-spanner-pg-adapter/gcr.io/$repo@$version \
45+
us-docker.pkg.dev/cloud-spanner-pg-adapter/gcr.io/$repo:no-new-use-public-image-$short_digest
46+
fi
47+
done
48+
done
49+
echo "Done! All non-latest images and manifests have been tagged."

0 commit comments

Comments
 (0)