Skip to content

Commit 104af60

Browse files
authored
Update docathon-assign.yml
1 parent bd9b57f commit 104af60

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

.github/workflows/docathon-assign.yml

+15-26
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,8 @@ jobs:
99
assign:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: Install Dependencies
13-
uses: actions/setup-node@v3
14-
with:
15-
node-version: '18'
16-
- name: Install @octokit/core
17-
run: |
18-
npm i @octokit/core @octokit/rest
19-
npm install cross-fetch
2012
- name: Check for "/assigntome" in comment
21-
uses: actions/github-script@v4
13+
uses: actions/github-script@v6
2214
env:
2315
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2416
with:
@@ -28,42 +20,39 @@ jobs:
2820
if (assignRegex.test(issueComment)) {
2921
const assignee = context.payload.comment.user.login;
3022
const issueNumber = context.payload.issue.number;
31-
const { Octokit } = require("@octokit/rest");
32-
const octokit = new Octokit({
33-
auth: process.env.GITHUB_TOKEN,
34-
request: {
35-
fetch: require('cross-fetch'),
36-
},
37-
});
38-
const { data: issue } = await octokit.issues.get({
39-
owner: context.repo.owner,
40-
repo: context.repo.repo,
41-
issue_number: issueNumber
42-
});
23+
try {
24+
const { data: issue } = await github.rest.issues.get({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
issue_number: issueNumber
28+
});
4329
const hasLabel = issue.labels.some(label => label.name === 'docathon-h2-2023');
4430
if (hasLabel) {
4531
if (issue.assignee !== null) {
46-
await octokit.issues.createComment({
32+
await github.rest.issues.createComment({
4733
owner: context.repo.owner,
4834
repo: context.repo.repo,
4935
issue_number: issueNumber,
50-
body: "The issue is already assigned. Please pick an opened and unnasigned issue with the [docathon-h2-2023 label](https://github.com/pytorch/tutorials/issues?q=is%3Aopen+is%3Aissue+label%3Adocathon-h2-2023)."
36+
body: "The issue is already assigned. Please pick an opened and unnasigned issue with the [docathon-h2-2023 label](https://github.com/pytorch/pytorch/issues?q=is%3Aopen+is%3Aissue+label%3Adocathon-h2-2023)."
5137
});
5238
} else {
53-
octokit.issues.addAssignees({
39+
await github.rest.issues.addAssignees({
5440
owner: context.repo.owner,
5541
repo: context.repo.repo,
5642
issue_number: issueNumber,
5743
assignees: [assignee]
5844
});
5945
}
6046
} else {
61-
const commmentMessage = "This issue does not have the correct label. Please pick an opened and unnasigned issue with the [docathon-h2-2023 label](https://github.com/pytorch/tutorials/issues?q=is%3Aopen+is%3Aissue+label%3Adocathon-h2-2023)."
62-
await octokit.issues.createComment({
47+
const commmentMessage = "This issue does not have the correct label. Please pick an opened and unnasigned issue with the [docathon-h2-2023 label](https://github.com/pytorch/pytorch/issues?q=is%3Aopen+is%3Aissue+label%3Adocathon-h2-2023)."
48+
await github.rest.issues.createComment({
6349
owner: context.repo.owner,
6450
repo: context.repo.repo,
6551
issue_number: issueNumber,
6652
body: commmentMessage
6753
});
54+
}
55+
} catch (error) {
56+
console.error(error);
6857
}
6958
}

0 commit comments

Comments
 (0)