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
2023-07-12 19:59:07 +02:00

153 lines
3.5 KiB
YAML

---
resource_types:
- name: apprise
type: registry-image
source:
repository: git.kun.is/pim/concourse-apprise-notifier
tag: "1.1.1"
resources:
- name: site-repo
type: git
source:
uri: https://git.kun.is/pim/static.git
icon: git
- name: site-registry-image
type: registry-image
source:
repository: git.kun.is/pim/static
username: pim
password: ((api_key))
tag: stable
icon: docker
- name: apprise-notification
type: apprise
source:
host: https://apprise.kun.is:444
key: concourse
icon: bell
- name: version
type: semver
source:
driver: git
initial_version: "1.1.0"
uri: ssh://git@git.kun.is:56287/pim/static.git
branch: version
file: version
private_key: {{private_key}}
icon: numeric
notify-failed: &notify-failed
put: apprise-notification
params:
body: "Failed to deploy static website!"
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
LABELS_FILE: site-repo/labels
run:
path: sh
args:
- -exc
- |
build
ls image
on_failure:
<< : *notify-failed
- get: version
params:
bump: patch
- put: site-registry-image
params:
image: image/image.tar
additional_tags: version/version
on_failure:
<< : *notify-failed
- put: version
params:
file: version/version
- name: deploy-static-website
plan:
- get: version
trigger: true
passed: [build-static-website]
- get: site-repo
- get: site-registry-image
passed: [build-static-website]
- 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
- name: version
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 version/version)/g" "site-repo/docker-stack.yml.template" > docker-stack.yml
cat docker-stack.yml
docker stack deploy --compose-file docker-stack.yml static
on_success:
put: apprise-notification
params:
title: "Static website deployed!"
body: "New version: $(cat version/version)"
no_get: true
on_failure:
<< : *notify-failed