Skip to content

Incompatible changes will lead to added labels and failing actions #12

Incompatible changes will lead to added labels and failing actions

Incompatible changes will lead to added labels and failing actions #12

name: Compatibility Check
on:
pull_request:
jobs:
compatible:
name: Is change incompatible
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
- name: Run script
id: check_incompatibility
run: |
cd .github/compatibility
npm ci
npm run check
- name: Add label PR on failure
if: failure() && steps.check_incompatibility.outcome == 'failure' # Only runs if your script failed.
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'incompatible-changes',
color: 'FF0000'
}).catch(err => console.log(`Label already exists`))
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['incompatible-changes']
})
github-token: ${{secrets.GITHUB_TOKEN}}
- name: Remove label PR on success
if: steps.check_incompatibility.outcome == 'success'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'incompatible-changes'
}).then(() => {
console.log('Label removed successfully!');
}).catch((error) => {
console.error('An error occurred while removing the label:', error);
})
github-token: ${{secrets.GITHUB_TOKEN}}