diff --git a/.github/workflows/gcp-lab.yml b/.github/workflows/gcp-lab.yml index 674792e..837eae3 100644 --- a/.github/workflows/gcp-lab.yml +++ b/.github/workflows/gcp-lab.yml @@ -67,6 +67,9 @@ on: pull_request_review: types: - submitted + pull_request_target: + types: + - labeled permissions: contents: read @@ -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' ) }} runs-on: ubuntu-latest @@ -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 @@ -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' }}"