2023-05-26 07:28:00 +00:00
|
|
|
---
|
2023-05-26 21:37:23 +00:00
|
|
|
resource_types:
|
|
|
|
- name: apprise
|
|
|
|
type: registry-image
|
|
|
|
source:
|
|
|
|
repository: git.pim.kunis.nl/pim/concourse-apprise-notifier
|
|
|
|
tag: 2f31a9abbbcdf29726e305cbf0702a581515f156eb5bfe09311a1232a941bb14
|
2023-05-26 07:28:00 +00:00
|
|
|
|
2023-05-19 22:19:33 +00:00
|
|
|
resources:
|
|
|
|
- name: site-repo
|
|
|
|
type: git
|
|
|
|
source:
|
2023-05-26 07:36:39 +00:00
|
|
|
uri: https://git.pim.kunis.nl/pim/static.git
|
2023-05-26 07:49:12 +00:00
|
|
|
icon: git
|
2023-05-19 22:19:33 +00:00
|
|
|
- name: site-registry-image
|
|
|
|
type: registry-image
|
|
|
|
source:
|
|
|
|
repository: git.pim.kunis.nl/pim/static
|
|
|
|
username: pim
|
2023-05-20 14:12:19 +00:00
|
|
|
password: ((api_key))
|
2023-05-26 07:49:12 +00:00
|
|
|
icon: docker
|
2023-05-26 21:37:23 +00:00
|
|
|
- name: apprise-notification
|
|
|
|
type: apprise
|
|
|
|
source:
|
|
|
|
host: https://apprise.pim.kunis.nl:444
|
|
|
|
key: concourse
|
|
|
|
icon: bell
|
|
|
|
|
|
|
|
notify-failed: ¬ify-failed
|
|
|
|
put: apprise-notification
|
|
|
|
params:
|
|
|
|
body: "Failed to deploy static website!"
|
|
|
|
no_get: true
|
2023-05-19 22:19:33 +00:00
|
|
|
|
|
|
|
jobs:
|
2023-05-26 09:01:33 +00:00
|
|
|
- name: build-static-website
|
2023-05-19 22:19:33 +00:00
|
|
|
plan:
|
|
|
|
- get: site-repo
|
|
|
|
trigger: true
|
|
|
|
- task: build-site
|
|
|
|
config:
|
|
|
|
platform: linux
|
|
|
|
image_resource:
|
|
|
|
type: registry-image
|
|
|
|
source:
|
2023-05-26 07:39:58 +00:00
|
|
|
repository: jekyll/builder
|
2023-05-19 22:19:33 +00:00
|
|
|
inputs:
|
|
|
|
- name: site-repo
|
|
|
|
outputs:
|
|
|
|
- name: site-html
|
|
|
|
params:
|
|
|
|
JEKYLL_ENV: production
|
|
|
|
run:
|
|
|
|
path: sh
|
|
|
|
args:
|
|
|
|
- -exc
|
|
|
|
- |
|
|
|
|
ls -lash
|
|
|
|
chown jekyll:jekyll site-html
|
|
|
|
cd site-repo/jekyll
|
|
|
|
bundle install
|
|
|
|
bundle exec jekyll build --disable-disk-cache --destination ../../site-html
|
2023-05-26 07:28:00 +00:00
|
|
|
on_failure:
|
|
|
|
<< : *notify-failed
|
2023-05-19 22:19:33 +00:00
|
|
|
- task: build-image
|
|
|
|
privileged: true
|
|
|
|
config:
|
|
|
|
platform: linux
|
|
|
|
image_resource:
|
|
|
|
type: registry-image
|
|
|
|
source:
|
|
|
|
repository: concourse/oci-build-task
|
|
|
|
inputs:
|
|
|
|
- name: site-repo
|
|
|
|
- name: site-html
|
|
|
|
outputs:
|
|
|
|
- name: image
|
|
|
|
params:
|
|
|
|
DOCKERFILE: site-repo/Dockerfile
|
|
|
|
run:
|
2023-05-20 14:12:19 +00:00
|
|
|
path: sh
|
|
|
|
args:
|
|
|
|
- -exc
|
|
|
|
- |
|
|
|
|
build
|
|
|
|
ls image
|
2023-05-20 14:31:55 +00:00
|
|
|
cat image/digest | cut -d ":" -f 2- > image/tag
|
2023-05-26 07:28:00 +00:00
|
|
|
on_failure:
|
|
|
|
<< : *notify-failed
|
2023-05-20 14:12:19 +00:00
|
|
|
- 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
|
2023-05-26 07:28:00 +00:00
|
|
|
on_failure:
|
|
|
|
<< : *notify-failed
|
2023-05-20 14:12:19 +00:00
|
|
|
- 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
|
2023-05-26 07:28:00 +00:00
|
|
|
on_failure:
|
|
|
|
<< : *notify-failed
|
2023-05-19 22:19:33 +00:00
|
|
|
- put: site-registry-image
|
|
|
|
params:
|
|
|
|
image: image/image.tar
|
2023-05-20 14:31:55 +00:00
|
|
|
additional_tags: image/tag
|
2023-05-26 07:28:00 +00:00
|
|
|
on_failure:
|
|
|
|
<< : *notify-failed
|
2023-05-26 09:01:33 +00:00
|
|
|
- name: deploy-static-website
|
|
|
|
plan:
|
|
|
|
- get: site-registry-image
|
|
|
|
trigger: true
|
2023-05-26 10:56:35 +00:00
|
|
|
passed: [build-static-website]
|
2023-05-26 09:01:33 +00:00
|
|
|
- get: site-repo
|
2023-05-19 23:33:36 +00:00
|
|
|
- task: deploy-site
|
|
|
|
config:
|
|
|
|
platform: linux
|
|
|
|
image_resource:
|
|
|
|
type: registry-image
|
|
|
|
source:
|
|
|
|
repository: raesene/alpine-containertools
|
|
|
|
params:
|
|
|
|
DOCKER_HOST: ssh://root@maestro.dmz
|
2023-05-20 14:31:55 +00:00
|
|
|
inputs:
|
|
|
|
- name: site-repo
|
2023-05-26 09:01:33 +00:00
|
|
|
- name: site-registry-image
|
2023-05-19 23:33:36 +00:00
|
|
|
run:
|
|
|
|
path: sh
|
|
|
|
args:
|
|
|
|
- -exc
|
|
|
|
- |
|
|
|
|
ls -lash
|
|
|
|
mkdir $HOME/.ssh
|
2023-05-20 14:31:55 +00:00
|
|
|
cp site-repo/ssh_config $HOME/.ssh/config
|
2023-05-19 23:33:36 +00:00
|
|
|
echo "((private_key))" > $HOME/.ssh/id_ed25519
|
|
|
|
chmod 600 $HOME/.ssh/id_ed25519
|
2023-05-26 09:01:33 +00:00
|
|
|
sed "s/TAG/$(cat site-registry-image/tag)/g" "site-repo/docker-stack.yml.template" > docker-stack.yml
|
2023-05-20 14:31:55 +00:00
|
|
|
docker stack deploy --compose-file docker-stack.yml static
|
2023-05-25 18:13:45 +00:00
|
|
|
on_success:
|
2023-05-26 21:37:23 +00:00
|
|
|
put: apprise-notification
|
|
|
|
params:
|
|
|
|
body: "Static website deployed!"
|
|
|
|
no_get: true
|
2023-05-26 07:28:00 +00:00
|
|
|
on_failure:
|
|
|
|
<< : *notify-failed
|