Repository navigation
Mock fs and repo paths before loading set-version in its test #14850
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: Analyze Pull Request | ||
|
Check warning on line 1 in .github/workflows/analyze-pr.yml
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, edited, reopened, synchronize] | ||
| permissions: | ||
| pull-requests: write | ||
| issues: write | ||
| jobs: | ||
| analyze_pr: | ||
| runs-on: ubuntu-latest | ||
| if: github.repository == 'react/react-native' | ||
| steps: | ||
| - name: Check out main branch | ||
| uses: actions/checkout@v6 | ||
| - name: Setup Node.js | ||
| uses: ./.github/actions/setup-node | ||
| - name: Run yarn install | ||
| uses: ./.github/actions/yarn-install | ||
| - name: Check PR body | ||
| id: check-pr-body | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const validatePRBody = require('./.github/workflow-scripts/validatePRBody.js'); | ||
| const {data: pullRequest} = await github.rest.pulls.get({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: context.issue.number, | ||
| }); | ||
| const {message, status} = validatePRBody(pullRequest.body); | ||
| core.setOutput('message', message); | ||
| core.setOutput('status', status); | ||
| - name: Check branch target | ||
| id: check-branch-target | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const checkBranchTarget = require('./.github/workflow-scripts/checkBranchTarget.js'); | ||
| const {data: pullRequest} = await github.rest.pulls.get({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: context.issue.number, | ||
| }); | ||
| const {data: basePullRequests} = await github.rest.pulls.list({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: 'open', | ||
| head: `${context.repo.owner}:${pullRequest.base.ref}`, | ||
| }); | ||
| const {message, status, shouldAddPickLabel} = checkBranchTarget( | ||
| pullRequest.base.ref, | ||
| basePullRequests.length > 0, | ||
| ); | ||
| if (shouldAddPickLabel) { | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| labels: ['Pick Request'], | ||
| }); | ||
| } | ||
| core.setOutput('message', message); | ||
| core.setOutput('status', status); | ||
| - name: Post PR comment | ||
| uses: ./.github/actions/post-pr-comment | ||
| with: | ||
| marker: '<!-- analyze-pr -->' | ||
| sections: '[${{ toJSON(steps.check-pr-body.outputs.message) }}, ${{ toJSON(steps.check-branch-target.outputs.message) }}]' | ||
| - name: Fail if validation errors | ||
| if: steps.check-pr-body.outputs.status == 'FAIL' || steps.check-branch-target.outputs.status == 'FAIL' | ||
| run: exit 1 | ||