delete old package releases

use digest as package tag
This commit is contained in:
Pim Kunis 2023-05-20 16:12:19 +02:00
parent a673ab047f
commit be32f23c79

View file

@ -7,9 +7,8 @@ resources:
type: registry-image
source:
repository: git.pim.kunis.nl/pim/static
tag: latest
username: pim
password: ((registry_token))
password: ((api_key))
jobs:
- name: build-and-deploy-static-website
@ -55,10 +54,50 @@ jobs:
params:
DOCKERFILE: site-repo/Dockerfile
run:
path: build
path: sh
args:
- -exc
- |
build
ls image
cat image/digest | cut -d ":" -f 2- > image/tags
- task: get-site-packages
config:
platform: linux
image_resource:
type: registry-image
source:
repository: badouralix/curl-jq
outputs:
- name: site-packages
run:
path: sh
args:
- -exc
- |
ls -lash
curl -X 'GET' 'https://git.pim.kunis.nl/api/v1/packages/pim?type=container&q=static' -H 'accept: application/json' | jq -rc 'map(.version) | .[]' > site-packages/packages.txt
cat site-packages/packages.txt
- task: delete-old-packages
config:
platform: linux
image_resource:
type: registry-image
source:
repository: badouralix/curl-jq
inputs:
- name: site-packages
run:
path: sh
args:
- -exc
- |
ls -lash
while read pkg; do curl -X 'DELETE' "https://git.pim.kunis.nl/api/v1/packages/pim/container/static/$pkg?token=((api_key))" -H 'accept: application/json'; done < site-packages/packages.txt
- put: site-registry-image
params:
image: image/image.tar
additional_tags: image/tags
- task: deploy-site
config:
platform: linux