Repository navigation
Fix Fork Pull Request Preview Discovery #2
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: Preview discovery diagnostics | |
| on: pull_request | |
| permissions: | |
| contents: read | |
| actions: read | |
| pull-requests: read | |
| jobs: | |
| inspect: | |
| # Temporary read-only diagnostics for the first live preview test. | |
| # Remove this workflow before the discovery fix is ready to merge. | |
| if: github.head_ref == 'pull-request-preview-discovery' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const { data: run } = await github.rest.actions.getWorkflowRun({ ...context.repo, run_id: 38304730526 }); | |
| const { data: workflow } = await github.rest.actions.getWorkflow({ ...context.repo, workflow_id: run.workflow_id }); | |
| const associated = await github.paginate(github.rest.repos.listPullRequestsAssociatedWithCommit, { ...context.repo, commit_sha: run.head_sha, per_page: 100 }); | |
| const { data: current } = await github.rest.pulls.get({ ...context.repo, pull_number: 1170 }); | |
| const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, { ...context.repo, run_id: run.id, per_page: 100 }); | |
| const open = await github.paginate(github.rest.pulls.list, { ...context.repo, state: 'open', per_page: 100 }); | |
| const describe = pr => ({ number: pr.number, state: pr.state, draft: pr.draft, sha: pr.head.sha, base: pr.base.repo.full_name }); | |
| core.info(JSON.stringify({ source: { repository: run.repository.full_name, event: run.event, conclusion: run.conclusion, sha: run.head_sha }, workflow: workflow.path, associated: associated.map(describe), current: describe(current), openMatches: open.filter(pr => pr.head.sha === run.head_sha).map(describe), artifacts: artifacts.map(a => ({ id: a.id, name: a.name, expired: a.expired })) }, null, 2)); | |
| const { findPreview } = await import(`${process.cwd()}/.github/scripts/preview-github.mts`); | |
| core.info(`Discovery result: ${JSON.stringify(await findPreview(github, run, context.repo))}`); |