Refactor: Test Projects code consistency #402
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pending Check (Manual CI) | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| jobs: | |
| mark-pending: | |
| name: Mark PR as Pending | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.draft == false | |
| permissions: | |
| statuses: write | |
| pull-requests: read | |
| steps: | |
| - name: Define contexts | |
| id: contexts | |
| run: | | |
| echo "list<<EOF" >> $GITHUB_OUTPUT | |
| echo "Manual MultiPlatform CI - Linux/x64" >> $GITHUB_OUTPUT | |
| echo "Manual MultiPlatform CI - Linux/arm64" >> $GITHUB_OUTPUT | |
| echo "Manual MultiPlatform CI - Windows/x64" >> $GITHUB_OUTPUT | |
| echo "Manual MultiPlatform CI - Windows/arm64" >> $GITHUB_OUTPUT | |
| echo "Manual MultiPlatform CI - macOS/x64" >> $GITHUB_OUTPUT | |
| echo "Manual MultiPlatform CI - macOS/arm64" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Set pending statuses | |
| if: github.event.pull_request.head.repo.fork == false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SHA: ${{ github.event.pull_request.head.sha }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} | |
| run: | | |
| set -euo pipefail | |
| API_BASE="https://api.github.com/repos/${HEAD_REPO}" | |
| WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/workflows/onPullRequest-multiPlatformTesting.yml" | |
| if [ -z "${SHA}" ] || [ "${SHA}" = "null" ]; then | |
| echo "Invalid PR head SHA: '${SHA}'" | |
| exit 1 | |
| fi | |
| echo "Validating SHA exists in PR head repository context..." | |
| commit_response="$(mktemp)" | |
| commit_status=$(curl -sS -o "$commit_response" -w "%{http_code}" \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "${API_BASE}/commits/${SHA}") | |
| if [ "$commit_status" -lt 200 ] || [ "$commit_status" -ge 300 ]; then | |
| echo "Commit lookup failed for SHA ${SHA} on PR #${PR_NUMBER} (HTTP ${commit_status})." | |
| echo "Response:" | |
| cat "$commit_response" | |
| rm -f "$commit_response" | |
| exit 1 | |
| fi | |
| rm -f "$commit_response" | |
| while read context; do | |
| echo "Setting pending for $context" | |
| payload=$(jq -nc \ | |
| --arg state "pending" \ | |
| --arg context "$context" \ | |
| --arg description "Waiting for manual trigger via workflow_dispatch." \ | |
| --arg target_url "$WORKFLOW_URL" \ | |
| '{state: $state, context: $context, description: $description, target_url: $target_url}') | |
| response_file="$(mktemp)" | |
| http_status=$(curl -sS -o "$response_file" -w "%{http_code}" -X POST \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "${API_BASE}/statuses/${SHA}" \ | |
| -d "$payload") | |
| if [ "$http_status" -lt 200 ] || [ "$http_status" -ge 300 ]; then | |
| echo "Failed to set pending status for '$context' (HTTP ${http_status})." | |
| echo "Response:" | |
| cat "$response_file" | |
| rm -f "$response_file" | |
| exit 1 | |
| fi | |
| rm -f "$response_file" | |
| done <<< "${{ steps.contexts.outputs.list }}" | |
| - name: Skip fork PRs | |
| if: github.event.pull_request.head.repo.fork == true | |
| run: | | |
| echo "Skipping pending status updates for fork PR #${{ github.event.pull_request.number }}." | |
| echo "GITHUB_TOKEN in pull_request_target does not have commit status write access on fork repositories." |