1
+ # This bot updates the issue with number DEPRECATION_TRACKER_ISSUE
2
+ # with the PR number that issued the deprecation.
3
+
4
+ # It runs on commits to main, and will trigger if the PR linked to a merged commit has the "Deprecate" label
1
5
name : Deprecations Bot
2
6
3
7
on :
4
- pull_request :
8
+ push :
5
9
branches :
6
10
- main
7
- types :
8
- [closed]
9
11
10
12
11
13
permissions :
@@ -15,17 +17,49 @@ jobs:
15
17
deprecation_update :
16
18
permissions :
17
19
issues : write
18
- if : >-
19
- contains(github.event.pull_request.labels.*.name, 'Deprecate') && github.event.pull_request.merged == true
20
20
runs-on : ubuntu-22.04
21
21
env :
22
22
DEPRECATION_TRACKER_ISSUE : 50578
23
23
steps :
24
- - name : Checkout
25
- run : |
26
- echo "Adding deprecation PR number to deprecation tracking issue"
27
- export PR=${{ github.event.pull_request.number }}
28
- BODY=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/issues/${DEPRECATION_TRACKER_ISSUE} |
29
- python3 -c "import sys, json, os; x = {'body': json.load(sys.stdin)['body']}; pr = os.environ['PR']; x['body'] += f'\n- [ ] #{pr}'; print(json.dumps(x))")
30
- echo ${BODY}
31
- curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X PATCH -d "${BODY}" https://api.github.com/repos/${{ github.repository }}/issues/${DEPRECATION_TRACKER_ISSUE}
24
+ - uses : actions/github-script@v6
25
+ id : update-deprecation-issue
26
+ with :
27
+ script : |
28
+ body = await github.rest.issues.get({
29
+ owner: context.repo.owner,
30
+ repo: context.repo.repo,
31
+ issue_number: ${{ env.DEPRECATION_TRACKER_ISSUE }},
32
+ })
33
+ body = body["data"]["body"];
34
+ linkedPRs = await github.rest.repos.listPullRequestsAssociatedWithCommit({
35
+ owner: context.repo.owner,
36
+ repo: context.repo.repo,
37
+ commit_sha: '${{ github.sha }}'
38
+ })
39
+ linkedPRs = linkedPRs["data"];
40
+ console.log(linkedPRs);
41
+ if (linkedPRs.length > 0) {
42
+ console.log("Found linked PR");
43
+ linkedPR = linkedPRs[0]
44
+ isDeprecation = false
45
+ for (label of linkedPR["labels"]) {
46
+ if (label["name"] == "Deprecate") {
47
+ isDeprecation = true;
48
+ break;
49
+ }
50
+ }
51
+
52
+ PR_NUMBER = linkedPR["number"];
53
+
54
+ body += ("\n- [ ] #" + PR_NUMBER);
55
+ if (isDeprecation) {
56
+ console.log("PR is a deprecation PR. Printing new body of issue");
57
+ console.log(body);
58
+ github.rest.issues.update({
59
+ owner: context.repo.owner,
60
+ repo: context.repo.repo,
61
+ issue_number: ${{ env.DEPRECATION_TRACKER_ISSUE }},
62
+ body: body
63
+ })
64
+ }
65
+ }
0 commit comments