This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
static/pipeline.yml

169 lines
4.2 KiB
YAML

---
resource_types:
- name: apprise
type: registry-image
source:
repository: git.pim.kunis.nl/pim/concourse-apprise-notifier
tag: 2f31a9abbbcdf29726e305cbf0702a581515f156eb5bfe09311a1232a941bb14
resources:
- name: site-repo
type: git
source:
uri: https://git.pim.kunis.nl/pim/static.git
icon: git
- name: site-registry-image
type: registry-image
source:
repository: git.pim.kunis.nl/pim/static
username: pim
password: ((api_key))
icon: docker
- name: apprise-notification
type: apprise
source:
host: https://apprise.pim.kunis.nl:444
key: concourse
icon: bell
notify-failed: &notify-failed
put: apprise-notification
params:
body: "Failed to deploy static website!"
no_get: true
jobs:
- name: build-static-website
plan:
- get: site-repo
trigger: true
- task: build-site
config:
platform: linux
image_resource:
type: registry-image
source:
repository: jekyll/builder
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
on_failure:
<< : *notify-failed
- 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:
path: sh
args:
- -exc
- |
build
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:
<< : *notify-failed
- put: site-registry-image
params:
image: image/image.tar
additional_tags: image/tag
on_failure:
<< : *notify-failed
- name: deploy-static-website
plan:
- get: site-registry-image
trigger: true
passed: [build-static-website]
- get: site-repo
- task: deploy-site
config:
platform: linux
image_resource:
type: registry-image
source:
repository: raesene/alpine-containertools
params:
DOCKER_HOST: ssh://root@maestro.dmz
inputs:
- name: site-repo
- name: site-registry-image
run:
path: sh
args:
- -exc
- |
ls -lash
mkdir $HOME/.ssh
cp site-repo/ssh_config $HOME/.ssh/config
echo "((private_key))" > $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
docker stack deploy --compose-file docker-stack.yml static
on_success:
put: apprise-notification
params:
body: "Static website deployed!"
no_get: true
on_failure:
<< : *notify-failed