let forgejo manage image versions

This commit is contained in:
Pim Kunis 2023-06-14 14:28:36 +02:00
parent 978e2f10ee
commit 7103d68c31
4 changed files with 5 additions and 44 deletions

View file

@ -2,5 +2,3 @@
My static website written in Jekyll. My static website written in Jekyll.
Deployment through Concourse. Deployment through Concourse.
`fly -t home set-pipeline --load-vars-from=secrets.yml -p static -c pipeline.yml`

1
deploy.yml Normal file
View file

@ -0,0 +1 @@
fly -t home set-pipeline -l secrets.yml -l vars.yml -p static -c pipeline.yml

View file

@ -4,7 +4,7 @@ resource_types:
type: registry-image type: registry-image
source: source:
repository: git.pim.kunis.nl/pim/concourse-apprise-notifier repository: git.pim.kunis.nl/pim/concourse-apprise-notifier
tag: 2f31a9abbbcdf29726e305cbf0702a581515f156eb5bfe09311a1232a941bb14 tag: 1.1
resources: resources:
- name: site-repo - name: site-repo
@ -18,6 +18,7 @@ resources:
repository: git.pim.kunis.nl/pim/static repository: git.pim.kunis.nl/pim/static
username: pim username: pim
password: ((api_key)) password: ((api_key))
tag: ((image_version))
icon: docker icon: docker
- name: apprise-notification - name: apprise-notification
type: apprise type: apprise
@ -30,7 +31,6 @@ notify-failed: &notify-failed
put: apprise-notification put: apprise-notification
params: params:
body: "Failed to deploy static website!" body: "Failed to deploy static website!"
no_get: true
jobs: jobs:
- name: build-static-website - name: build-static-website
@ -84,50 +84,11 @@ jobs:
- | - |
build build
ls image ls image
cat image/digest | cut -d ":" -f 2- > image/tag
on_failure:
<< : *notify-failed
- 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
on_failure:
<< : *notify-failed
- 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
on_failure: on_failure:
<< : *notify-failed << : *notify-failed
- put: site-registry-image - put: site-registry-image
params: params:
image: image/image.tar image: image/image.tar
additional_tags: image/tag
on_failure: on_failure:
<< : *notify-failed << : *notify-failed
- name: deploy-static-website - name: deploy-static-website
@ -158,7 +119,7 @@ jobs:
cp site-repo/ssh_config $HOME/.ssh/config cp site-repo/ssh_config $HOME/.ssh/config
echo "((private_key))" > $HOME/.ssh/id_ed25519 echo "((private_key))" > $HOME/.ssh/id_ed25519
chmod 600 $HOME/.ssh/id_ed25519 chmod 600 $HOME/.ssh/id_ed25519
sed "s/TAG/$(cat site-registry-image/tag)/g" "site-repo/docker-stack.yml.template" > docker-stack.yml sed "s/TAG/((image_version))/g" "site-repo/docker-stack.yml.template" > docker-stack.yml
docker stack deploy --compose-file docker-stack.yml static docker stack deploy --compose-file docker-stack.yml static
on_success: on_success:
put: apprise-notification put: apprise-notification

1
vars.yml Normal file
View file

@ -0,0 +1 @@
image_version: "1.1"