matrix-service-synapse/.woodpecker.yml

120 lines
3.5 KiB
YAML
Raw Permalink Normal View History

2022-08-21 09:53:54 -04:00
variables:
&vars
- REGISTRY=code.balsillie.net
- REGISTRY_USER=michael
- ORGANIZATION=containers
- SOURCE_ORGANIZATION=mirrors
- REPO=matrix-service-synapse
2022-08-22 01:40:03 -04:00
- BUILD_ARGS=PYTHON_VERSION=3.9
2022-08-21 09:53:54 -04:00
- DOCKERFILE=docker/Dockerfile
- CONTEXT=.
- WATCHTOWER_HOST=watchtower.balsillie.net
2022-08-21 10:36:50 -04:00
- MATRIX_HOST=matrix.balsillie.net
- MATRIX_PORT=443
- MATRIX_ROOM=!HdSXmuHcBMaYExEfkh:balsillie.net
2022-08-21 09:53:54 -04:00
2022-08-21 06:21:11 -04:00
workspace:
base: /git
path: pipeline
clone:
git:
image: woodpeckerci/plugin-git
2022-08-20 03:25:33 -04:00
pipeline:
2022-08-21 07:43:37 -04:00
2022-08-21 06:21:11 -04:00
check-tag:
2022-08-21 10:55:35 -04:00
image: code.balsillie.net/containers/woodpecker-util
2022-08-21 09:53:54 -04:00
pull: true
2022-08-20 03:25:33 -04:00
commands:
2022-08-21 09:59:01 -04:00
- /bin/bash /git/pipeline/check-tag.sh
2022-08-21 07:43:37 -04:00
2022-08-21 06:21:11 -04:00
clone-source:
image: docker:git
2022-08-21 07:41:10 -04:00
environment:
2022-08-21 09:53:54 -04:00
*vars
2022-08-21 07:41:10 -04:00
commands:
2022-08-21 09:53:54 -04:00
- git clone "https://$${REGISTRY}/$${SOURCE_ORGANIZATION}/$${REPO}.git" /git/$${REPO}
- cd /git/$${REPO}
- pwd
- git checkout ${TAG}
- ls
2022-08-21 07:43:37 -04:00
2022-08-21 06:21:11 -04:00
docker-build:
image: docker:latest
secrets:
- source: REGISTRY_PASSWORD
target: REGISTRY_PASSWORD
2022-08-21 08:02:05 -04:00
volumes:
- /var/run/docker.sock:/var/run/docker.sock
2022-08-21 07:41:10 -04:00
environment:
2022-08-21 10:36:50 -04:00
*vars
2022-08-21 06:21:11 -04:00
commands:
- export DOCKER_BUILDKIT=1
2022-08-21 08:07:50 -04:00
- cd /git/$${REPO}
2022-08-21 09:53:54 -04:00
- pwd
- ls
2022-08-21 07:58:33 -04:00
- echo $REGISTRY_PASSWORD | docker login $REGISTRY -u $REGISTRY_USER --password-stdin
2022-08-21 07:33:27 -04:00
- docker build
2022-08-21 09:55:55 -04:00
-t $REGISTRY/$ORGANIZATION/$REPO:$TAG
2022-08-21 07:58:33 -04:00
-t $REGISTRY/$ORGANIZATION/$REPO:$(date +%F)
-t $REGISTRY/$ORGANIZATION/$REPO:latest
2022-08-21 07:33:27 -04:00
--pull
2022-08-21 08:17:28 -04:00
--build-arg $${BUILD_ARGS}
2022-08-21 08:07:50 -04:00
-f $${DOCKERFILE}
2022-08-21 08:17:28 -04:00
$${CONTEXT}
2022-08-21 09:53:54 -04:00
- docker push -a $REGISTRY/$ORGANIZATION/$REPO
2022-08-21 10:36:50 -04:00
trigger-watchtower:
2022-08-21 10:55:35 -04:00
image: code.balsillie.net/containers/woodpecker-util
2022-08-21 09:53:54 -04:00
pull: false
environment:
*vars
secrets:
- source: WATCHTOWER_HTTP_API_TOKEN
target: WATCHTOWER_HTTP_API_TOKEN
commands:
2022-08-21 11:06:12 -04:00
- HEADER='Authorization:'
2022-08-21 22:38:10 -04:00
- HEADER=$HEADER" Bearer $${WATCHTOWER_HTTP_API_TOKEN}"
- curl -H "$${HEADER}" -i "https://$${WATCHTOWER_HOST}/v1/update"
2022-08-21 10:36:50 -04:00
2022-08-21 22:58:38 -04:00
# need a status check here that the container has come back up healthy
# something like while [ $(docker ps -q --filter "name=matrix_svc_synapse" --filter "status=running" --filter "health=healthy" --filter "label=$TAG") -z ]
# loop until container comes up successfully, with a max timeout
# exit 1 and write /git/pipeline/reason if the timeout hits
# remove the sleep in notify-success below once complete
2022-08-21 20:42:28 -04:00
notify-matrix-success:
2022-08-21 10:55:35 -04:00
image: code.balsillie.net/containers/woodpecker-util
2022-08-21 10:36:50 -04:00
pull: false
environment:
*vars
secrets:
- source: MATRIX_ACCESS_TOKEN
target: MATRIX_ACCESS_TOKEN
commands:
- sleep 60
2022-08-21 10:36:50 -04:00
- shoutrrr send
2022-08-21 20:50:16 -04:00
--url matrix://:$${MATRIX_ACCESS_TOKEN}@$${MATRIX_HOST}:$${MATRIX_PORT}/?rooms=$${MATRIX_ROOM}
2022-08-21 20:42:28 -04:00
--message "New image build of $${ORGANIZATION}/$${REPO}, $${TAG}, has completed and been deployed."
when:
status:
- success
notify-matrix-failure:
image: code.balsillie.net/containers/woodpecker-util
pull: false
environment:
*vars
secrets:
- source: MATRIX_ACCESS_TOKEN
target: MATRIX_ACCESS_TOKEN
commands:
2022-08-21 20:50:16 -04:00
- REASON='Reason:'
- REASON=$REASON$(cat /git/pipeline/reason)
2022-08-21 20:42:28 -04:00
- shoutrrr send
2022-08-21 20:50:16 -04:00
--url matrix://:$${MATRIX_ACCESS_TOKEN}@$${MATRIX_HOST}:$${MATRIX_PORT}/?rooms=$${MATRIX_ROOM}
--message "New image build of $${ORGANIZATION}/$${REPO}, $${TAG}, has failed. $${REASON}"
2022-08-21 20:42:28 -04:00
when:
status:
- failure