-
Notifications
You must be signed in to change notification settings - Fork 56
69 lines (61 loc) · 2.01 KB
/
json-compatibility.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Experimental Compatibility Check
on:
pull_request:
permissions:
issues: write
jobs:
compatible:
name: Is change compatible
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.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'incompatible-changes',
color: 'FF0000'
}).catch(err => console.log(`Label already exists`))
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}}