Foundation / checks (checks) (push) Successful in 35s
Foundation / checks (ecs) (push) Successful in 17s
Foundation / checks (network) (push) Successful in 18s
Foundation / checks (postgres) (push) Successful in 24s
Foundation / checks (deploy) (push) Successful in 3m15s
Foundation / checks (tsan) (push) Successful in 5m51s
Foundation / checks (client) (push) Failing after 27m3s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
84 lines
3.0 KiB
YAML
84 lines
3.0 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: Prepare pinned kustomize
|
|
run: |
|
|
set -eu
|
|
bash tools/ci/prepare-kustomize.sh
|
|
|
|
- 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
|