diff --git a/.github/workflows/chek-prod-release.yml b/.github/workflows/chek-prod-release.yml index b4014318ea9..a8f1cda6d87 100644 --- a/.github/workflows/chek-prod-release.yml +++ b/.github/workflows/chek-prod-release.yml @@ -7,20 +7,14 @@ on: - "!v*-dirty*" workflow_dispatch: inputs: - source_repository: - description: "Source repository to build from" - required: true - default: "multica-ai/multica" - type: string source_ref: - description: "Git ref to build from (tag, branch, or SHA)" + description: "chekdata/multica ref to build from (tag, branch, or SHA)" required: true - default: "v0.4.3" + default: "main" type: string image_tag: description: "Image tag to publish" required: true - default: "v0.4.3" type: string permissions: @@ -36,7 +30,7 @@ env: WEB_IMAGE: ghcr.io/chekdata/multica-web jobs: - build-and-open-gitops-pr: + build-and-dispatch-domestic-promotion: runs-on: ubuntu-latest permissions: contents: read @@ -53,7 +47,7 @@ jobs: run: | set -euo pipefail if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then - source_repository="${{ inputs.source_repository }}" + source_repository="${{ github.repository }}" source_ref="${{ inputs.source_ref }}" image_tag="${{ inputs.image_tag }}" else @@ -71,9 +65,11 @@ jobs: exit 1 fi - echo "source_repository=$source_repository" >> "$GITHUB_OUTPUT" - echo "source_ref=$source_ref" >> "$GITHUB_OUTPUT" - echo "image_tag=$image_tag" >> "$GITHUB_OUTPUT" + { + echo "source_repository=$source_repository" + echo "source_ref=$source_ref" + echo "image_tag=$image_tag" + } >> "$GITHUB_OUTPUT" - name: Checkout source repository uses: actions/checkout@v4 @@ -87,9 +83,11 @@ jobs: shell: bash run: | set -euo pipefail - echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - echo "commit_short=$(git rev-parse --short=7 HEAD)" >> "$GITHUB_OUTPUT" - echo "commit_date=$(git show -s --format=%cI HEAD)" >> "$GITHUB_OUTPUT" + { + echo "commit=$(git rev-parse HEAD)" + echo "commit_short=$(git rev-parse --short=7 HEAD)" + echo "commit_date=$(git show -s --format=%cI HEAD)" + } >> "$GITHUB_OUTPUT" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -135,56 +133,27 @@ jobs: build-args: | NEXT_PUBLIC_APP_VERSION=${{ steps.vars.outputs.image_tag }} - - name: Checkout ops-bootstrap - uses: actions/checkout@v4 - with: - repository: chekdata/ops-bootstrap - ref: main - token: ${{ secrets.OPS_BOOTSTRAP_TOKEN }} - path: ops-bootstrap - - - name: Update multica prod manifests + - name: Dispatch domestic image promotion shell: bash + env: + GH_TOKEN: ${{ secrets.OPS_BOOTSTRAP_TOKEN }} + IMAGE_TAG: ${{ steps.vars.outputs.image_tag }} + SOURCE_COMMIT: ${{ steps.source_meta.outputs.commit }} run: | set -euo pipefail - python3 - <<'PY' - import pathlib - import re - - path = pathlib.Path("ops-bootstrap/apps/multica/prod/deployment.yaml") - text = path.read_text(encoding="utf-8") - replacements = { - r"ghcr\.io/[^/\s]+/multica-backend:[^\s]+": "${{ env.BACKEND_IMAGE }}:${{ steps.vars.outputs.image_tag }}", - r"ghcr\.io/[^/\s]+/multica-web:[^\s]+": "${{ env.WEB_IMAGE }}:${{ steps.vars.outputs.image_tag }}", - } - updated = text - for pattern, replacement in replacements.items(): - updated = re.sub(pattern, replacement, updated) - if updated != text: - path.write_text(updated, encoding="utf-8") - else: - print("manifest already references requested images") - PY - - - name: Create pull request in ops-bootstrap - id: cpr - uses: peter-evans/create-pull-request@v6 - with: - path: ops-bootstrap - token: ${{ secrets.OPS_BOOTSTRAP_TOKEN }} - commit-message: "chore(prod): bump multica image to ${{ steps.vars.outputs.image_tag }}" - title: "chore(prod): bump multica image to ${{ steps.vars.outputs.image_tag }}" - body: | - This PR is auto-generated by `chek-prod-release.yml`. - - - source repository: `${{ steps.vars.outputs.source_repository }}` - - source ref: `${{ steps.vars.outputs.source_ref }}` - - source commit: `${{ steps.source_meta.outputs.commit }}` - - backend image: `${{ env.BACKEND_IMAGE }}:${{ steps.vars.outputs.image_tag }}` - - web image: `${{ env.WEB_IMAGE }}:${{ steps.vars.outputs.image_tag }}` - base: main - branch: bot/image-bump/multica/${{ steps.vars.outputs.image_tag }} - delete-branch: true + jq -n \ + --arg image_tag "${IMAGE_TAG}" \ + --arg source_commit "${SOURCE_COMMIT}" \ + '{ + event_type: "multica-prod-images", + client_payload: { + image_tag: $image_tag, + source_commit: $source_commit + } + }' | gh api \ + --method POST \ + repos/chekdata/ops-bootstrap/dispatches \ + --input - - name: Append release summary shell: bash @@ -197,9 +166,5 @@ jobs: echo "- Source commit: \`${{ steps.source_meta.outputs.commit }}\`" echo "- Backend image: \`${{ env.BACKEND_IMAGE }}:${{ steps.vars.outputs.image_tag }}\`" echo "- Web image: \`${{ env.WEB_IMAGE }}:${{ steps.vars.outputs.image_tag }}\`" - if [[ -n "${{ steps.cpr.outputs.pull-request-url }}" ]]; then - echo "- GitOps PR: ${{ steps.cpr.outputs.pull-request-url }}" - else - echo "- GitOps PR: no manifest diff was created" - fi + echo "- Domestic promotion: dispatched to [ops-bootstrap](https://github.com/chekdata/ops-bootstrap/actions/workflows/promote-multica-prod-images.yml)" } >> "$GITHUB_STEP_SUMMARY"