feat: deploy via ljwx-deploy GitOps — add deploy-pr job and fix apply-sync-autopr defaults
- build-and-notify.yml: add deploy-pr job that clones BrunoGaoSZ/ljwx-deploy, updates apps/agent-platform/overlays/prod/kustomization.yaml with sha-<7> tag, and creates a PR (auto-merged by branch protection) - apply-sync-autopr.sh: fix defaults → DEPLOY_REPO_OWNER=BrunoGaoSZ, DEPLOY_REPO_NAME=ljwx-deploy Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
dec280ad40
commit
343b188138
@@ -69,6 +69,81 @@ jobs:
|
||||
cache-from: type=gha,scope=api-ghcr
|
||||
cache-to: type=gha,scope=api-ghcr,mode=max
|
||||
|
||||
deploy-pr:
|
||||
name: Create Deploy PR
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-api
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install PyYAML
|
||||
shell: bash
|
||||
run: python3 -m pip install --quiet pyyaml
|
||||
|
||||
- name: Clone ljwx-deploy
|
||||
env:
|
||||
DEPLOY_REPO_TOKEN: ${{ secrets.DEPLOY_REPO_TOKEN }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${DEPLOY_REPO_TOKEN:-}" ]; then
|
||||
echo "DEPLOY_REPO_TOKEN is required" && exit 1
|
||||
fi
|
||||
git clone \
|
||||
"https://x-access-token:${DEPLOY_REPO_TOKEN}@github.com/BrunoGaoSZ/ljwx-deploy.git" \
|
||||
deploy-repo
|
||||
|
||||
- name: Update overlay kustomization
|
||||
env:
|
||||
IMAGE_NAME: harbor.eu.lingjingwanxiang.cn/ljwx/agent-platform-api
|
||||
IMAGE_TAG: sha-${{ needs.build-api.outputs.short_sha }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python3 - <<'PY'
|
||||
import os
|
||||
from pathlib import Path
|
||||
import yaml
|
||||
|
||||
overlay = Path("deploy-repo/apps/agent-platform/overlays/prod/kustomization.yaml")
|
||||
data = yaml.safe_load(overlay.read_text()) or {}
|
||||
|
||||
for img in data.get("images", []):
|
||||
if img.get("name") == os.environ["IMAGE_NAME"]:
|
||||
img["newTag"] = os.environ["IMAGE_TAG"]
|
||||
|
||||
overlay.write_text(yaml.safe_dump(data, sort_keys=False))
|
||||
PY
|
||||
|
||||
- name: Create deploy PR
|
||||
working-directory: deploy-repo
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.DEPLOY_REPO_TOKEN }}
|
||||
GIT_SHA: ${{ github.sha }}
|
||||
SHORT_SHA: sha-${{ needs.build-api.outputs.short_sha }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
BRANCH="sync/release-agent-platform-${GITHUB_RUN_ID}"
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git checkout -b "${BRANCH}"
|
||||
git add apps/agent-platform/overlays/prod/kustomization.yaml
|
||||
git commit -m "release(agent-platform): ${SHORT_SHA}"
|
||||
git push origin "${BRANCH}"
|
||||
gh pr create \
|
||||
--repo "BrunoGaoSZ/ljwx-deploy" \
|
||||
--title "release(agent-platform): ${SHORT_SHA}" \
|
||||
--body "Automated release PR from BrunoGao/agent-platform@${GIT_SHA}
|
||||
|
||||
**API** \`harbor.eu.lingjingwanxiang.cn/ljwx/agent-platform-api:${SHORT_SHA}\`
|
||||
" \
|
||||
--base main \
|
||||
--head "${BRANCH}"
|
||||
|
||||
notify-sync-service:
|
||||
name: Notify Sync Service
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -13,8 +13,8 @@ DEPLOY_AUTOPR_BRANCH_PREFIX="${DEPLOY_AUTOPR_BRANCH_PREFIX:-sync}"
|
||||
DEPLOY_AUTOPR_CLOSE_SUPERSEDED_PRS="${DEPLOY_AUTOPR_CLOSE_SUPERSEDED_PRS:-true}"
|
||||
DEPLOY_AUTOPR_AUTO_MERGE_ENABLED="${DEPLOY_AUTOPR_AUTO_MERGE_ENABLED:-false}"
|
||||
DEPLOY_AUTOPR_AUTO_MERGE_METHOD="${DEPLOY_AUTOPR_AUTO_MERGE_METHOD:-squash}"
|
||||
DEPLOY_REPO_OWNER="${DEPLOY_REPO_OWNER:-BrunoGao}"
|
||||
DEPLOY_REPO_NAME="${DEPLOY_REPO_NAME:-agent-deploy}"
|
||||
DEPLOY_REPO_OWNER="${DEPLOY_REPO_OWNER:-BrunoGaoSZ}"
|
||||
DEPLOY_REPO_NAME="${DEPLOY_REPO_NAME:-ljwx-deploy}"
|
||||
DEPLOY_REPO_BASE_BRANCH="${DEPLOY_REPO_BASE_BRANCH:-main}"
|
||||
DEPLOY_REPO_FILE_PATH="${DEPLOY_REPO_FILE_PATH:-apps/agent-platform/overlays/prod/kustomization.yaml}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user