Skip to content

Commit 044cb83

Browse files
committed
try and fix trigger
1 parent 3714857 commit 044cb83

File tree

1 file changed

+111
-112
lines changed

1 file changed

+111
-112
lines changed

.github/workflows/pr-label-automation.yml

Lines changed: 111 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -10,165 +10,164 @@ permissions:
1010

1111
jobs:
1212
auto-label:
13-
if: github.event.issue.pull_request
13+
# Only run on pull request comments
14+
if: github.event.issue.pull_request != null
1415
runs-on: ubuntu-latest
1516
steps:
16-
- name: Check for breaking change command
17-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
18-
with:
19-
script: |
20-
const comment = context.payload.comment.body.trim();
21-
if (comment !== '/breaking-change') {
22-
return;
23-
}
24-
25-
await github.rest.issues.addLabels({
17+
- name: Add breaking change label
18+
if: github.event.comment.body == '/breaking-change'
19+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
20+
with:
21+
script: |
22+
// Add the breaking change label
23+
await github.rest.issues.addLabels({
24+
owner: context.repo.owner,
25+
repo: context.repo.repo,
26+
issue_number: context.issue.number,
27+
labels: ['breaking change']
28+
});
29+
30+
// React to the comment to show it was processed
31+
await github.rest.reactions.createForIssueComment({
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
comment_id: context.payload.comment.id,
35+
content: '+1'
36+
});
37+
38+
// Add a reply comment to confirm the action
39+
await github.rest.issues.createComment({
40+
owner: context.repo.owner,
41+
repo: context.repo.repo,
42+
issue_number: context.issue.number,
43+
body: '✅ Added `breaking change` label to this PR.'
44+
});
45+
46+
- name: Add deprecation label
47+
if: github.event.comment.body == '/deprecation'
48+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
49+
with:
50+
script: |
51+
// Add the deprecation label
52+
await github.rest.issues.addLabels({
53+
owner: context.repo.owner,
54+
repo: context.repo.repo,
55+
issue_number: context.issue.number,
56+
labels: ['deprecation']
57+
});
58+
59+
// React to the comment to show it was processed
60+
await github.rest.reactions.createForIssueComment({
61+
owner: context.repo.owner,
62+
repo: context.repo.repo,
63+
comment_id: context.payload.comment.id,
64+
content: '+1'
65+
});
66+
67+
// Add a reply comment to confirm the action
68+
await github.rest.issues.createComment({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
issue_number: context.issue.number,
72+
body: '✅ Added `deprecation` label to this PR.'
73+
});
74+
75+
- name: Remove breaking change label
76+
if: github.event.comment.body == '/remove-breaking-change'
77+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
78+
with:
79+
script: |
80+
try {
81+
// Remove the breaking change label
82+
await github.rest.issues.removeLabel({
2683
owner: context.repo.owner,
2784
repo: context.repo.repo,
2885
issue_number: context.issue.number,
29-
labels: ['breaking change']
86+
name: 'breaking change'
3087
});
3188
89+
// React to the comment to show it was processed
3290
await github.rest.reactions.createForIssueComment({
3391
owner: context.repo.owner,
3492
repo: context.repo.repo,
3593
comment_id: context.payload.comment.id,
3694
content: '+1'
3795
});
3896
97+
// Add a reply comment to confirm the action
3998
await github.rest.issues.createComment({
4099
owner: context.repo.owner,
41100
repo: context.repo.repo,
42101
issue_number: context.issue.number,
43-
body: '✅ Added `breaking change` label to this PR.'
102+
body: '✅ Removed `breaking change` label from this PR.'
44103
});
104+
} catch (error) {
105+
if (error.status === 404) {
106+
// Label doesn't exist on the PR
107+
await github.rest.reactions.createForIssueComment({
108+
owner: context.repo.owner,
109+
repo: context.repo.repo,
110+
comment_id: context.payload.comment.id,
111+
content: 'confused'
112+
});
45113
46-
- name: Check for deprecation command
47-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
48-
with:
49-
script: |
50-
const comment = context.payload.comment.body.trim();
51-
if (comment !== '/deprecation') {
52-
return;
114+
await github.rest.issues.createComment({
115+
owner: context.repo.owner,
116+
repo: context.repo.repo,
117+
issue_number: context.issue.number,
118+
body: '⚠️ The `breaking change` label was not found on this PR.'
119+
});
120+
} else {
121+
throw error;
53122
}
54-
55-
await github.rest.issues.addLabels({
123+
}
124+
125+
- name: Remove deprecation label
126+
if: github.event.comment.body == '/remove-deprecation'
127+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
128+
with:
129+
script: |
130+
try {
131+
// Remove the deprecation label
132+
await github.rest.issues.removeLabel({
56133
owner: context.repo.owner,
57134
repo: context.repo.repo,
58135
issue_number: context.issue.number,
59-
labels: ['deprecation']
136+
name: 'deprecation'
60137
});
61138
139+
// React to the comment to show it was processed
62140
await github.rest.reactions.createForIssueComment({
63141
owner: context.repo.owner,
64142
repo: context.repo.repo,
65143
comment_id: context.payload.comment.id,
66144
content: '+1'
67145
});
68146
147+
// Add a reply comment to confirm the action
69148
await github.rest.issues.createComment({
70149
owner: context.repo.owner,
71150
repo: context.repo.repo,
72151
issue_number: context.issue.number,
73-
body: '✅ Added `deprecation` label to this PR.'
152+
body: '✅ Removed `deprecation` label from this PR.'
74153
});
75-
76-
- name: Check for remove breaking change command
77-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
78-
with:
79-
script: |
80-
const comment = context.payload.comment.body.trim();
81-
if (comment !== '/remove-breaking-change') {
82-
return;
83-
}
84-
85-
try {
86-
await github.rest.issues.removeLabel({
87-
owner: context.repo.owner,
88-
repo: context.repo.repo,
89-
issue_number: context.issue.number,
90-
name: 'breaking change'
91-
});
92-
154+
} catch (error) {
155+
if (error.status === 404) {
156+
// Label doesn't exist on the PR
93157
await github.rest.reactions.createForIssueComment({
94158
owner: context.repo.owner,
95159
repo: context.repo.repo,
96160
comment_id: context.payload.comment.id,
97-
content: '+1'
161+
content: 'confused'
98162
});
99163
100164
await github.rest.issues.createComment({
101165
owner: context.repo.owner,
102166
repo: context.repo.repo,
103167
issue_number: context.issue.number,
104-
body: '✅ Removed `breaking change` label from this PR.'
105-
});
106-
} catch (error) {
107-
if (error.status === 404) {
108-
await github.rest.reactions.createForIssueComment({
109-
owner: context.repo.owner,
110-
repo: context.repo.repo,
111-
comment_id: context.payload.comment.id,
112-
content: 'confused'
113-
});
114-
115-
await github.rest.issues.createComment({
116-
owner: context.repo.owner,
117-
repo: context.repo.repo,
118-
issue_number: context.issue.number,
119-
body: '⚠️ The `breaking change` label was not found on this PR.'
120-
});
121-
} else {
122-
throw error;
123-
}
124-
}
125-
126-
- name: Check for remove deprecation command
127-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
128-
with:
129-
script: |
130-
const comment = context.payload.comment.body.trim();
131-
if (comment !== '/remove-deprecation') {
132-
return;
133-
}
134-
135-
try {
136-
await github.rest.issues.removeLabel({
137-
owner: context.repo.owner,
138-
repo: context.repo.repo,
139-
issue_number: context.issue.number,
140-
name: 'deprecation'
168+
body: '⚠️ The `deprecation` label was not found on this PR.'
141169
});
142-
143-
await github.rest.reactions.createForIssueComment({
144-
owner: context.repo.owner,
145-
repo: context.repo.repo,
146-
comment_id: context.payload.comment.id,
147-
content: '+1'
148-
});
149-
150-
await github.rest.issues.createComment({
151-
owner: context.repo.owner,
152-
repo: context.repo.repo,
153-
issue_number: context.issue.number,
154-
body: '✅ Removed `deprecation` label from this PR.'
155-
});
156-
} catch (error) {
157-
if (error.status === 404) {
158-
await github.rest.reactions.createForIssueComment({
159-
owner: context.repo.owner,
160-
repo: context.repo.repo,
161-
comment_id: context.payload.comment.id,
162-
content: 'confused'
163-
});
164-
165-
await github.rest.issues.createComment({
166-
owner: context.repo.owner,
167-
repo: context.repo.repo,
168-
issue_number: context.issue.number,
169-
body: '⚠️ The `deprecation` label was not found on this PR.'
170-
});
171-
} else {
172-
throw error;
173-
}
170+
} else {
171+
throw error;
174172
}
173+
}

0 commit comments

Comments
 (0)