diff --git a/.github/workflows/auto-ff-matrix-pilot-sync.yml b/.github/workflows/auto-ff-matrix-pilot-sync.yml index 2f0f7cb17fd..ef286b368fa 100644 --- a/.github/workflows/auto-ff-matrix-pilot-sync.yml +++ b/.github/workflows/auto-ff-matrix-pilot-sync.yml @@ -11,6 +11,7 @@ on: - completed permissions: + actions: write contents: write pull-requests: write @@ -126,3 +127,10 @@ jobs: fi git push origin "${actual_head}:refs/heads/${BASE_BRANCH}" + + - name: Dispatch deployment mirror + if: steps.checks.outputs.ready == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: | + gh workflow run mirror-to-deployment-target.yml --ref "${BASE_BRANCH}" diff --git a/.github/workflows/mirror-to-deployment-target.yml b/.github/workflows/mirror-to-deployment-target.yml index 6fa4274db01..5504cfab959 100644 --- a/.github/workflows/mirror-to-deployment-target.yml +++ b/.github/workflows/mirror-to-deployment-target.yml @@ -1,6 +1,7 @@ name: Mirror to deployment target on: + workflow_dispatch: push: branches: - native-matrix-channel-pilot diff --git a/scripts/test-auto-ff-matrix-pilot-sync-workflow.sh b/scripts/test-auto-ff-matrix-pilot-sync-workflow.sh new file mode 100755 index 00000000000..5bd75b715c5 --- /dev/null +++ b/scripts/test-auto-ff-matrix-pilot-sync-workflow.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -euo pipefail + +cd "$(dirname "$0")/.." + +workflow=".github/workflows/auto-ff-matrix-pilot-sync.yml" +mirror_workflow=".github/workflows/mirror-to-deployment-target.yml" + +if [[ ! -f "${workflow}" ]]; then + echo "missing ${workflow}" + exit 1 +fi + +if [[ ! -f "${mirror_workflow}" ]]; then + echo "missing ${mirror_workflow}" + exit 1 +fi + +require_in() { + local file="$1" + local pattern="$2" + local description="$3" + if ! grep -Eq -- "${pattern}" "${file}"; then + echo "missing ${description}: ${pattern}" + exit 1 + fi +} + +require_in "${workflow}" 'name:[[:space:]]*Auto fast-forward Matrix pilot sync' "workflow name" +require_in "${workflow}" 'workflow_run:' "workflow-run trigger" +require_in "${workflow}" 'actions:[[:space:]]*write' "Actions write permission for workflow dispatch" +require_in "${workflow}" 'BASE_BRANCH:[[:space:]]*native-matrix-channel-pilot' "Matrix pilot branch" +require_in "${workflow}" 'git push origin "\$\{actual_head\}:refs/heads/\$\{BASE_BRANCH\}"' "pilot branch fast-forward" +require_in "${workflow}" 'name:[[:space:]]*Dispatch deployment mirror' "post-fast-forward mirror dispatch step" +require_in "${workflow}" 'GH_TOKEN:[[:space:]]*\$\{\{ github\.token \}\}' "dispatch token" +require_in "${workflow}" 'gh workflow run mirror-to-deployment-target\.yml --ref "\$\{BASE_BRANCH\}"' "explicit deployment mirror dispatch" +require_in "${mirror_workflow}" 'workflow_dispatch:' "manual mirror dispatch trigger" +require_in "${mirror_workflow}" 'branches:' "push trigger branch restriction" +require_in "${mirror_workflow}" 'native-matrix-channel-pilot' "Matrix pilot push trigger" + +echo "auto-ff Matrix pilot workflow contract OK"