Skip to content

Commit 9288a28

Browse files
lithomas1im-vinicius
authored and
im-vinicius
committed
CI: Fix the deprecation bot (pandas-dev#53593)
* CI: Fix the deprecation tracking bot * Update deprecation-tracking-bot.yml * Update deprecation-tracking-bot.yml * Updates * Update deprecation-tracking-bot.yml
1 parent ec94ef1 commit 9288a28

File tree

1 file changed

+47
-13
lines changed

1 file changed

+47
-13
lines changed
+47-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
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
15
name: Deprecations Bot
26

37
on:
4-
pull_request:
8+
push:
59
branches:
610
- main
7-
types:
8-
[closed]
911

1012

1113
permissions:
@@ -15,17 +17,49 @@ jobs:
1517
deprecation_update:
1618
permissions:
1719
issues: write
18-
if: >-
19-
contains(github.event.pull_request.labels.*.name, 'Deprecate') && github.event.pull_request.merged == true
2020
runs-on: ubuntu-22.04
2121
env:
2222
DEPRECATION_TRACKER_ISSUE: 50578
2323
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

Comments
 (0)