Deliver the lab from manifests rendered from score-lab.yaml
deploy/lab is rendered by score-k8s with the platform's provisioners and replaces the hand-written deploy/manifests. The lab build workflow now renders and commits it after the build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
name: Build and Push to ACR (lab)
|
||||
|
||||
# Dispatch only while the lab path is proven. Build and deploy the SAME commit: the deploy tags
|
||||
# the image with the commit it was dispatched from.
|
||||
# Dispatch only while the lab path is proven. Builds the image for the dispatched commit, then
|
||||
# renders score-lab.yaml with the platform's provisioners and commits the result to deploy/lab,
|
||||
# which Argo CD delivers.
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
|
||||
@@ -11,6 +12,13 @@ concurrency:
|
||||
|
||||
env:
|
||||
AZURE_FEDERATED_TOKEN_FILE: /var/run/secrets/azure/tokens/azure-identity-token
|
||||
ACR_LOGIN_SERVER: cruciblecoredevacr.azurecr.io
|
||||
# Platform provisioners release. Upgrading is a change to this pin.
|
||||
PROVISIONERS_VERSION: v0.1.0
|
||||
SCORE_K8S_VERSION: 0.19.0
|
||||
SCORE_K8S_SHA256: 7c62f3585f1864cad7c4032557e183cb65fef22a7a15f3cbe22365849ca95e2c
|
||||
ORAS_VERSION: 1.2.3
|
||||
ORAS_SHA256: b4efc97a91f471f323f193ea4b4d63d8ff443ca3aab514151a30751330852827
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -78,3 +86,76 @@ jobs:
|
||||
echo "| **Service** | demo-vivek-11 |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Commit** | ${{ gitea.sha }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Image** | $IMAGE_FULL |" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
render:
|
||||
name: Render manifests
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install tools
|
||||
run: |
|
||||
command -v az &>/dev/null || curl -sL https://aka.ms/InstallAzureCLIDeb | bash
|
||||
python3 -c 'import yaml' 2>/dev/null || (apt-get update -qq && apt-get install -y python3-yaml)
|
||||
mkdir -p "$HOME/bin" && cd "$(mktemp -d)"
|
||||
curl -fsSL -o score-k8s.tgz "https://github.com/score-spec/score-k8s/releases/download/${SCORE_K8S_VERSION}/score-k8s_${SCORE_K8S_VERSION}_linux_amd64.tar.gz"
|
||||
curl -fsSL -o oras.tgz "https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz"
|
||||
echo "${SCORE_K8S_SHA256} score-k8s.tgz" | sha256sum -c -
|
||||
echo "${ORAS_SHA256} oras.tgz" | sha256sum -c -
|
||||
tar -xzf score-k8s.tgz score-k8s && tar -xzf oras.tgz oras
|
||||
install -m 0755 score-k8s oras "$HOME/bin/"
|
||||
echo "$HOME/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Azure login (OIDC)
|
||||
run: |
|
||||
az login \
|
||||
--service-principal \
|
||||
--username "$AZURE_CLIENT_ID" \
|
||||
--tenant "$AZURE_TENANT_ID" \
|
||||
--federated-token "$(cat $AZURE_FEDERATED_TOKEN_FILE)"
|
||||
|
||||
- name: Pull platform provisioners
|
||||
run: |
|
||||
az acr login --name "${ACR_LOGIN_SERVER%%.*}" --expose-token --output tsv --query accessToken \
|
||||
| oras login "$ACR_LOGIN_SERVER" --username 00000000-0000-0000-0000-000000000000 --password-stdin
|
||||
oras pull "${ACR_LOGIN_SERVER}/score-provisioners:${PROVISIONERS_VERSION}" -o "$HOME/provisioners"
|
||||
ls -1 "$HOME/provisioners"
|
||||
|
||||
- name: Render score-lab.yaml
|
||||
run: |
|
||||
P="$HOME/provisioners"
|
||||
OUT="$PWD/deploy/lab"
|
||||
WORK="$(mktemp -d)"
|
||||
cp score-lab.yaml "$WORK/score.yaml"
|
||||
cd "$WORK"
|
||||
score-k8s init --no-sample --quiet \
|
||||
$(for f in "$P"/*.provisioners.yaml; do printf -- '--provisioners %s ' "$f"; done) \
|
||||
$(for f in "$P"/*.tpl.yaml; do printf -- '--patch-templates %s ' "$f"; done)
|
||||
# Platform rule: only the platform's provisioners, so an unsupported resource type fails.
|
||||
rm -f .score-k8s/zz-default.provisioners.yaml
|
||||
CRUCIBLE_ENV=lab score-k8s generate score.yaml --quiet \
|
||||
--image "${ACR_LOGIN_SERVER}/demo-vivek-11:${{ gitea.sha }}" \
|
||||
--namespace demo-vivek-11 \
|
||||
-o manifests.yaml
|
||||
python3 "$P/policy-check.py" manifests.yaml
|
||||
python3 "$P/split.py" manifests.yaml "$OUT"
|
||||
|
||||
- name: Commit rendered manifests
|
||||
run: |
|
||||
git config user.name "gitea-actions"
|
||||
git config user.email "gitea-actions@noreply.gitea.kyndemo.live"
|
||||
git add deploy/lab
|
||||
if git diff --cached --quiet; then
|
||||
echo "deploy/lab is already up to date"
|
||||
exit 0
|
||||
fi
|
||||
SHA="${{ gitea.sha }}"
|
||||
git commit -m "deploy(lab): render ${SHA:0:12} [skip ci]"
|
||||
git pull --rebase origin "${{ gitea.ref_name }}"
|
||||
git push origin "HEAD:${{ gitea.ref_name }}"
|
||||
|
||||
Reference in New Issue
Block a user