83 lines
3.1 KiB
YAML
83 lines
3.1 KiB
YAML
kind: pipeline
|
|
name: build-and-deploy
|
|
type: docker
|
|
|
|
platform:
|
|
os: linux
|
|
arch: arm64
|
|
|
|
|
|
steps:
|
|
- name: docker-build-and-push
|
|
image: thegeeklab/drone-docker-buildx # Absurd that this isn't offered as first-party!
|
|
privileged: true
|
|
settings:
|
|
# Consider testing with this if the cache-to arguments don't help!
|
|
# args:
|
|
# - BUILDKIT_INLINE_CACHE=1
|
|
cache_from:
|
|
- "gitea.scubbo.org/${DRONE_REPO}:${DRONE_BRANCH}"
|
|
cache_to:
|
|
# https://docs.docker.com/build/cache/backends/registry/
|
|
# `mode=max` necessary in order to cache intermediate stages
|
|
#
|
|
# https://github.com/go-gitea/gitea/issues/28973#issuecomment-1961859655
|
|
# Some parameters are necessary in order to make the push to gitea succeed
|
|
#
|
|
# Another reference:
|
|
# https://github.com/thegeeklab/drone-docker-buildx/issues/47
|
|
- "type=registry,ref=gitea.scubbo.org/${DRONE_REPO}:${DRONE_BRANCH},mode=max,image-manifest=true,oci-mediatypes=true"
|
|
registry: gitea.scubbo.org
|
|
username: scubbo
|
|
password:
|
|
from_secret: gitea_password
|
|
repo: gitea.scubbo.org/${DRONE_REPO}
|
|
tags:
|
|
- ${DRONE_BRANCH}
|
|
- ${DRONE_COMMIT_SHA:0:10}
|
|
target: prod
|
|
platforms:
|
|
- linux/arm64
|
|
- linux/amd64
|
|
|
|
- name: Update Helm Chart
|
|
image: alpine
|
|
environment:
|
|
GITEA_PASSWORD:
|
|
from_secret: gitea_password
|
|
GITEA_PAT:
|
|
from_secret: gitea_pat
|
|
commands:
|
|
# Cannot use `drone/git` plugin because:
|
|
# * it cannot check out to a different directory
|
|
# * if you try to clear the main directory and use it to checkout, Drone will just re-clone the original repo
|
|
# between steps
|
|
# ...God, I really need to transition off of Drone and onto a better CI tool...
|
|
- find . -not -path '.' | xargs rm -rf
|
|
- find . -not -path '.'
|
|
- apk add yq git
|
|
- git clone https://scubbo:${GITEA_PASSWORD}@gitea.scubbo.org/scubbo/helm-charts.git
|
|
- cd helm-charts
|
|
- cat charts/edh-elo/values.yaml
|
|
- yq -i '.image.tag = "${DRONE_COMMIT_SHA:0:10}"' charts/edh-elo/values.yaml
|
|
- git add -A
|
|
- git -c user.name="Imagebot" -c user.email="fake@scubbo.org" commit -m 'Update EDH ELO commit to "${DRONE_COMMIT_SHA:0:10}"'
|
|
- git remote add origin-with-credentials "https://scubbo:$GITEA_PAT@gitea.scubbo.org/scubbo/helm-charts.git"
|
|
- git push origin-with-credentials main:main
|
|
|
|
- name: update-argo
|
|
image: curlimages/curl
|
|
environment:
|
|
ARGO_TOKEN:
|
|
from_secret: argo_token
|
|
commands:
|
|
- "curl -sS -X POST \"argo-cd-argocd-server.argo.svc.cluster.local/api/v1/applications/edh-elo/sync\" -H \"Authorization: Bearer ${ARGO_TOKEN}\" -H \"Content-Type: application/json\""
|
|
|
|
- name: purge-cache
|
|
image: curlimages/curl
|
|
environment:
|
|
CLOUDFLARE_TOKEN:
|
|
from_secret: cloudflare_token
|
|
commands:
|
|
- "curl -sS -X POST \"https://api.cloudflare.com/client/v4/zones/c86d55d225ed973d5da45239beac2f99/purge_cache\" -H \"Authorization: Bearer ${CLOUDFLARE_TOKEN}\" -H \"Content-Type:application/json\" -d '{\"files\":[\"https://edh-elo.scubbo.org/*\"]}'"
|