From f97954885f1c283080bdbe48035c5f3ad8177c73 Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Tue, 13 Oct 2026 19:26:43 +0800 Subject: [PATCH] ci: add Harbor-only mono-engine deploy workflow Migrate mono-engine-deploy from mega to mega2, adapted for the single-crate layout and without AWS/ECR or ECS redeploy. --- .github/workflows/mono-engine-deploy.yml | 73 ++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/mono-engine-deploy.yml diff --git a/.github/workflows/mono-engine-deploy.yml b/.github/workflows/mono-engine-deploy.yml new file mode 100644 index 00000000..c683e201 --- /dev/null +++ b/.github/workflows/mono-engine-deploy.yml @@ -0,0 +1,73 @@ +name: Mono Engine deploy +on: + push: + branches: + - main + paths: + - ".github/workflows/mono-engine-deploy.yml" + - "src/**" + - "config/**" + - "Cargo.toml" + - "Cargo.lock" + - "Dockerfile" + - ".dockerignore" + +env: + REPOSITORY: mega2/mega2 + IMAGE_TAG_BASE: latest + HARBOR_REGISTRY: registry.xuanwu.openatom.cn + +# actions: write is required for docker buildx --cache-{from,to} type=gha. +permissions: + contents: read + actions: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-push: + runs-on: ubuntu-latest + timeout-minutes: 60 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Expose ACTIONS_RUNTIME_TOKEN / ACTIONS_RESULTS_URL for raw + # `docker buildx --cache-{from,to} type=gha` in the build step. + - name: Expose GitHub Actions runtime env + uses: crazy-max/ghaction-github-runtime@v3 + + - name: Login to Harbor + uses: docker/login-action@v3 + with: + registry: ${{ env.HARBOR_REGISTRY }} + username: ${{ secrets.HARBOR_USERNAME }} + password: ${{ secrets.HARBOR_PASSWORD }} + + - name: Build & push image + run: | + set -euo pipefail + + HARBOR_BASE="${{ env.HARBOR_REGISTRY }}/${{ env.REPOSITORY }}" + SHORT_SHA="${GITHUB_SHA:0:7}" + TAG_BASE="${{ env.IMAGE_TAG_BASE }}" + CACHE_SCOPE="mega2-amd64" + + echo "HARBOR_IMAGE=$HARBOR_BASE:$TAG_BASE" + echo "HARBOR_SHA=$HARBOR_BASE:$SHORT_SHA" + echo "CACHE_SCOPE=$CACHE_SCOPE" + + docker buildx build \ + --cache-from type=gha,scope=$CACHE_SCOPE \ + --cache-to type=gha,mode=max,scope=$CACHE_SCOPE \ + --provenance=false \ + --sbom=false \ + -f ./Dockerfile \ + -t "$HARBOR_BASE:$TAG_BASE" \ + -t "$HARBOR_BASE:$SHORT_SHA" \ + --push .