-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
65 lines (58 loc) · 1.91 KB
/
deprecation-tracking-bot.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
# This bot updates the issue with number DEPRECATION_TRACKER_ISSUE
# with the PR number that issued the deprecation.
# It runs on commits to main, and will trigger if the PR linked to a merged commit has the "Deprecate" label
name: Deprecations Bot
on:
push:
branches:
- main
permissions:
contents: read
jobs:
deprecation_update:
permissions:
issues: write
runs-on: ubuntu-22.04
env:
DEPRECATION_TRACKER_ISSUE: 50578
steps:
- uses: actions/github-script@v6
id: update-deprecation-issue
with:
script: |
body = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ env.DEPRECATION_TRACKER_ISSUE }},
})
body = body["data"]["body"];
linkedPRs = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: '${{ github.sha }}'
})
linkedPRs = linkedPRs["data"];
console.log(linkedPRs);
if (linkedPRs.length > 0) {
console.log("Found linked PR");
linkedPR = linkedPRs[0]
isDeprecation = false
for (label of linkedPR["labels"]) {
if (label["name"] == "Deprecate") {
isDeprecation = true;
break;
}
}
PR_NUMBER = linkedPR["number"];
body += ("\n- [ ] #" + PR_NUMBER);
if (isDeprecation) {
console.log("PR is a deprecation PR. Printing new body of issue");
console.log(body);
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ env.DEPRECATION_TRACKER_ISSUE }},
body: body
})
}
}