name: lab-e2e-trigger
on:
pull_request:
types: [ready_for_review, labeled]
permissions: {}
jobs:
lab-e2e-trigger:
if: >-
!github.event.pull_request.draft
&& github.event.pull_request.head.repo.full_name == github.repository
&& (github.event.action == 'ready_for_review' || github.event.label.name == 'lab-e2e')
runs-on: cpu
timeout-minutes: 3
env:
GH_TOKEN: ${{ secrets.ZLAB_CI_TOKEN }}
BRANCH: ${{ github.event.pull_request.head.ref }}
SHA: ${{ github.event.pull_request.head.sha }}
PR: ${{ github.event.pull_request.number }}
PR_BODY: ${{ github.event.pull_request.body }}
GH_VERSION: "2.101.0"
steps:
- name: Dispatch lab-e2e in zakuro-ai/zak-platform-dev
run: |
if [ -z "$GH_TOKEN" ]; then
echo "::error::secret ZLAB_CI_TOKEN is not set for this repo (zak-platform-dev scripts/ci/setup-x399-runner.sh, step 2/2)"
exit 1
fi
if ! command -v gh >/dev/null; then # the ARC image is minimal
mkdir -p "$RUNNER_TEMP/gh" && cd "$RUNNER_TEMP/gh"
base=https://github.com/cli/cli/releases/download/v$GH_VERSION
curl -fsSLO "$base/gh_${GH_VERSION}_linux_amd64.tar.gz"
curl -fsSL "$base/gh_${GH_VERSION}_checksums.txt" | grep "gh_${GH_VERSION}_linux_amd64.tar.gz" | sha256sum -c --quiet
tar -xzf "gh_${GH_VERSION}_linux_amd64.tar.gz" --strip-components=2 "gh_${GH_VERSION}_linux_amd64/bin/gh"
export PATH="$PWD:$PATH"
fi
# Only the body's `lab:` lines travel (zlab parses and validates them there).
LINES=$(printf '%s\n' "$PR_BODY" | grep -iE '^[[:space:]]*([-*>][[:space:]]*)?`?lab:' || true)
gh workflow run lab-e2e.yml -R zakuro-ai/zak-platform-dev --ref master \
-f zc_ref="$BRANCH" -f origin_repo="$GITHUB_REPOSITORY" -f origin_sha="$SHA" -f origin_pr="$PR" \
-f lab_lines="$LINES"
echo "lab e2e dispatched for $GITHUB_REPOSITORY#$PR ($SHA): https://github.com/zakuro-ai/zak-platform-dev/actions/workflows/lab-e2e.yml"
echo "the result arrives as the commit status lab-e2e on $SHA"