update associated issue check #12940
Workflow file for this run
This file contains 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: PR files | |
on: | |
pull_request: | |
types: | |
- 'opened' | |
- 'reopened' | |
- 'synchronize' | |
- 'labeled' | |
- 'unlabeled' | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
changed-files-in-pr: | |
name: 'Check for changed files' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'package-lock.json matches package.json' | |
uses: brettcannon/check-for-changed-files@v1.2.1 | |
with: | |
prereq-pattern: 'package.json' | |
file-pattern: 'package-lock.json' | |
skip-label: 'skip package*.json' | |
failure-message: '${prereq-pattern} was edited but ${file-pattern} was not (the ${skip-label} label can be used to pass this check)' | |
- name: 'package.json matches package-lock.json' | |
uses: brettcannon/check-for-changed-files@v1.2.1 | |
with: | |
prereq-pattern: 'package-lock.json' | |
file-pattern: 'package.json' | |
skip-label: 'skip package*.json' | |
failure-message: '${prereq-pattern} was edited but ${file-pattern} was not (the ${skip-label} label can be used to pass this check)' | |
- name: 'Tests' | |
uses: brettcannon/check-for-changed-files@v1.2.1 | |
with: | |
prereq-pattern: src/**/*.ts | |
file-pattern: | | |
src/**/*.test.ts | |
src/**/*.testvirtualenvs.ts | |
.github/test_plan.md | |
skip-label: 'skip tests' | |
failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)' | |
- name: Add "issue-please" Label | |
uses: actions-ecosystem/action-add-labels@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
labels: 'issue-please' | |
- name: 'Ensure PR has an associated issue' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const labels = context.payload.pull_request.labels.map(label => label.name); | |
if (labels.includes('issue-please')) { | |
core.setFailed('The "issue-please" label is present. Please associate an issue and remove the label.'); | |
} | |
if (!labels.includes('skip-issue-check')) { | |
const issueLink = context.payload.pull_request.body.match(/https:\/\/github\.com\/\S+\/issues\/\d+/); | |
if (!issueLink) { | |
core.setFailed('No associated issue found in the PR description.'); | |
} | |
} |