Renovate only runs at 03:00 UTC, so a release waited up to a day for its deploy PR. Dispatch renovate.yml right after the image is pushed. It needs DEPLOYMENTS_DISPATCH_TOKEN (the job token can't dispatch in another repo); when that is missing or the call fails, it warns and the release still succeeds, since the image is already pushed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.4 KiB
YAML
60 lines
2.4 KiB
YAML
name: Release
|
|
|
|
# Builds and pushes the image. Production runs from ygg/deployments: Renovate
|
|
# opens a PR there for the new version, and merging it deploys.
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
|
|
jobs:
|
|
image:
|
|
runs-on: rocky-10
|
|
steps:
|
|
- name: Check out source
|
|
uses: actions/checkout@v4
|
|
|
|
# The shared ygg action builds ./Dockerfile as
|
|
# git.app.ygg/mtps/tern-server, tagged with the version (v stripped)
|
|
# and latest, with OCI source/revision/created/version labels. It logs
|
|
# in through a temporary DOCKER_CONFIG, so the token never lands in the
|
|
# runner's ~/.docker, and builds with --progress=plain.
|
|
- name: Build and push image
|
|
id: image
|
|
uses: https://git.app.ygg/ygg/actions/push-image@v2
|
|
with:
|
|
registry-token: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Show image
|
|
env:
|
|
TAGS: ${{ steps.image.outputs.tags }}
|
|
DIGEST: ${{ steps.image.outputs.digest }}
|
|
run: |
|
|
printf 'tags: %s\ndigest: %s\n' "$TAGS" "$DIGEST"
|
|
|
|
# Renovate in ygg/deployments otherwise only runs at 03:00 UTC, so
|
|
# start it now to open the deploy PR within minutes. The job token
|
|
# can't dispatch in another repo, so this needs a token with
|
|
# write:repository from an account with write access to ygg/deployments.
|
|
# The image is already pushed: anything going wrong here is a warning,
|
|
# never a failed release.
|
|
- name: Start Renovate in ygg/deployments
|
|
env:
|
|
TOKEN: ${{ secrets.DEPLOYMENTS_DISPATCH_TOKEN }}
|
|
API: ${{ gitea.api_url }}
|
|
run: |
|
|
if [ -z "$TOKEN" ]; then
|
|
echo "::warning::DEPLOYMENTS_DISPATCH_TOKEN is not set; Renovate opens the deploy PR at its next 03:00 UTC run"
|
|
exit 0
|
|
fi
|
|
body=$(mktemp)
|
|
code=$(curl -sS --max-time 30 -o "$body" -w '%{http_code}' -X POST \
|
|
-H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
|
|
-d '{"ref":"main"}' \
|
|
"$API/repos/ygg/deployments/actions/workflows/renovate.yml/dispatches") || code="curl failed"
|
|
if [ "$code" = 204 ]; then
|
|
echo "Renovate started: https://git.app.ygg/ygg/deployments/actions?workflow=renovate.yml"
|
|
else
|
|
echo "::warning::Could not start Renovate in ygg/deployments ($code): $(head -c 300 "$body")"
|
|
fi
|
|
rm -f "$body"
|