Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/gcp-lab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ on:
pull_request_review:
types:
- submitted
pull_request_target:
types:
- labeled

permissions:
contents: read
Expand All @@ -84,8 +87,14 @@ jobs:
${{
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'pull_request_review' &&
github.event.review.state == 'approved' &&
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.review.author_association)
) ||
(
github.event_name == 'pull_request_target' &&
github.event.action == 'labeled' &&
github.event.label.name == 'run-gcp-lab'
Comment on lines +95 to +97

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict the label trigger to trusted maintainers

When this workflow is enabled on repos that grant non-maintainers triage access, this condition lets them trigger the GCP lab just by applying run-gcp-lab—GitHub documents that anyone with triage access can apply labels. That label path has id-token: write and eventually scripts/lab/gcp/run-smoke.sh clones and executes the PR head on a GCP VM, so the approval/maintainer association check used for pull_request_review should also be enforced here or verified through the API before starting cloud resources.

Useful? React with 👍 / 👎.

)
}}
runs-on: ubuntu-latest
Expand All @@ -102,7 +111,7 @@ jobs:
- name: Check out trusted workflow repository
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request_review' && github.event.pull_request.base.sha || github.sha }}
ref: ${{ github.event.pull_request.base.sha || github.sha }}

- name: Set up JDK
uses: actions/setup-java@v4
Expand Down Expand Up @@ -140,10 +149,10 @@ jobs:
shell: bash
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" == "pull_request_review" ]]; then
pr_number="${{ github.event.pull_request.number }}"
ref="${{ github.event.pull_request.head.sha }}"
repo_url="${{ github.event.pull_request.head.repo.clone_url }}"
if [[ "${GITHUB_EVENT_NAME}" != "workflow_dispatch" ]]; then
pr_number="$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")"
ref="$(jq -r '.pull_request.head.sha' "$GITHUB_EVENT_PATH")"
repo_url="$(jq -r '.pull_request.head.repo.clone_url' "$GITHUB_EVENT_PATH")"
name="openphone-lab-pr-${pr_number}-${{ github.run_id }}-${{ github.run_attempt }}"
runtime="local"
arch="${{ vars.OPENPHONE_EMULATOR_ARCH || 'x86_64' }}"
Expand Down
Loading