Files
aevolution/.gitea/workflows/promote-dev.yaml
T
aevolution-gitops-bot 6ba7f85d7d
Foundation / checks (client) (push) Successful in 14s
Foundation / checks (checks) (push) Successful in 15s
Foundation / checks (ecs) (push) Successful in 15s
Foundation / checks (network) (push) Successful in 15s
Foundation / checks (postgres) (push) Successful in 1m21s
Foundation / checks (deploy) (push) Successful in 2m58s
Foundation / checks (tsan) (push) Successful in 5m41s
Foundation / image (push) Successful in 11s
Foundation / server-image (push) Successful in 33s
Foundation / postgres-tools (push) Successful in 49s
Install PyYAML in promotion workflows
2026-10-05 08:29:17 -04:00

79 lines
2.9 KiB
YAML

name: Promote server image to dev
on:
workflow_dispatch:
inputs:
image_digest:
description: 'Immutable aevolution-server digest, including sha256:'
required: true
type: string
concurrency:
group: promote-server-dev
cancel-in-progress: false
permissions:
contents: write
jobs:
promote:
runs-on: ${{ vars.CI_RUNNER_LABEL || 'ubuntu-22.04' }}
steps:
- name: Checkout main
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
ref: main
fetch-depth: 0
persist-credentials: true
- name: Install deploy policy dependencies
run: |
set -eu
python3 -m pip install --user --break-system-packages \
--disable-pip-version-check PyYAML
- name: Update dev image and build identity
env:
IMAGE_DIGEST: ${{ inputs.image_digest }}
run: |
set -eu
python3 - <<'PY'
import os, re
digest = os.environ['IMAGE_DIGEST'].strip()
if not re.fullmatch(r'sha256:[0-9a-f]{64}', digest):
raise SystemExit('image_digest must be sha256: followed by 64 lowercase hexadecimal characters')
build = digest[7:]
files = [
'deploy/kubernetes/region/dev/kustomization.yaml',
'deploy/kubernetes/region/dev/region-values.yaml',
]
for name in files:
text = open(name, encoding='utf-8').read()
if name.endswith('kustomization.yaml'):
text, count = re.subn(r'(?m)^ digest: sha256:[0-9a-f]{64}$', f' digest: {digest}', text)
if count != 1:
raise SystemExit(f'{name}: expected one server digest, found {count}')
else:
text, count = re.subn(r'(?m)(name: REGION_BUILD, value: )[0-9a-f]{64}', rf'\g<1>{build}', text)
if count != 2:
raise SystemExit(f'{name}: expected two REGION_BUILD values, found {count}')
open(name, 'w', encoding='utf-8').write(text)
print(f'Promoting dev to {digest}')
PY
- name: Validate and commit promotion
run: |
set -eu
git diff --check
python3 tools/ci/deploy-policy-check.py
git diff --quiet -- \
deploy/kubernetes/region/dev/kustomization.yaml \
deploy/kubernetes/region/dev/region-values.yaml && {
echo 'dev already points at this image'; exit 0;
}
git config user.name 'aevolution-gitops-bot'
git config user.email 'aevolution-gitops-bot@aeternalisgames.com'
git add deploy/kubernetes/region/dev/kustomization.yaml deploy/kubernetes/region/dev/region-values.yaml
git commit -m "deploy(dev): promote selected server image"
git push origin HEAD:main