matrix-service-synapse/.woodpecker.yml
Michael Balsillie 43ea6507de
Some checks failed
ci/woodpecker/tag/woodpecker Pipeline failed
revert to python 3.9
2022-08-22 17:40:03 +12:00

120 lines
3.5 KiB
YAML

variables:
&vars
- REGISTRY=code.balsillie.net
- REGISTRY_USER=michael
- ORGANIZATION=containers
- SOURCE_ORGANIZATION=mirrors
- REPO=matrix-service-synapse
- BUILD_ARGS=PYTHON_VERSION=3.9
- DOCKERFILE=docker/Dockerfile
- CONTEXT=.
- WATCHTOWER_HOST=watchtower.balsillie.net
- MATRIX_HOST=matrix.balsillie.net
- MATRIX_PORT=443
- MATRIX_ROOM=!HdSXmuHcBMaYExEfkh:balsillie.net
workspace:
base: /git
path: pipeline
clone:
git:
image: woodpeckerci/plugin-git
pipeline:
check-tag:
image: code.balsillie.net/containers/woodpecker-util
pull: true
commands:
- /bin/bash /git/pipeline/check-tag.sh
clone-source:
image: docker:git
environment:
*vars
commands:
- git clone "https://$${REGISTRY}/$${SOURCE_ORGANIZATION}/$${REPO}.git" /git/$${REPO}
- cd /git/$${REPO}
- pwd
- git checkout ${TAG}
- ls
docker-build:
image: docker:latest
secrets:
- source: REGISTRY_PASSWORD
target: REGISTRY_PASSWORD
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
*vars
commands:
- export DOCKER_BUILDKIT=1
- cd /git/$${REPO}
- pwd
- ls
- echo $REGISTRY_PASSWORD | docker login $REGISTRY -u $REGISTRY_USER --password-stdin
- docker build
-t $REGISTRY/$ORGANIZATION/$REPO:$TAG
-t $REGISTRY/$ORGANIZATION/$REPO:$(date +%F)
-t $REGISTRY/$ORGANIZATION/$REPO:latest
--pull
--build-arg $${BUILD_ARGS}
-f $${DOCKERFILE}
$${CONTEXT}
- docker push -a $REGISTRY/$ORGANIZATION/$REPO
trigger-watchtower:
image: code.balsillie.net/containers/woodpecker-util
pull: false
environment:
*vars
secrets:
- source: WATCHTOWER_HTTP_API_TOKEN
target: WATCHTOWER_HTTP_API_TOKEN
commands:
- HEADER='Authorization:'
- HEADER=$HEADER" Bearer $${WATCHTOWER_HTTP_API_TOKEN}"
- curl -H "$${HEADER}" -i "https://$${WATCHTOWER_HOST}/v1/update"
# 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
notify-matrix-success:
image: code.balsillie.net/containers/woodpecker-util
pull: false
environment:
*vars
secrets:
- source: MATRIX_ACCESS_TOKEN
target: MATRIX_ACCESS_TOKEN
commands:
- sleep 60
- shoutrrr send
--url matrix://:$${MATRIX_ACCESS_TOKEN}@$${MATRIX_HOST}:$${MATRIX_PORT}/?rooms=$${MATRIX_ROOM}
--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:
- REASON='Reason:'
- REASON=$REASON$(cat /git/pipeline/reason)
- shoutrrr send
--url matrix://:$${MATRIX_ACCESS_TOKEN}@$${MATRIX_HOST}:$${MATRIX_PORT}/?rooms=$${MATRIX_ROOM}
--message "New image build of $${ORGANIZATION}/$${REPO}, $${TAG}, has failed. $${REASON}"
when:
status:
- failure