-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (65 loc) · 2.21 KB
/
make-it-taylors-version.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
66
67
68
name: Make it Taylor's Version
permissions:
issues: write
pull-requests: write
discussions: write
on:
issues:
types:
- opened
pull_request:
types:
- opened
- ready_for_review
discussion:
types:
- created
jobs:
add-label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
let type = '';
let item = null;
if (context.payload.issue) {
item = context.payload.issue;
type = 'issue';
} else if (context.payload.pull_request) {
item = context.payload.pull_request;
type = 'pull_request';
} else if (context.payload.discussion) {
item = context.payload.discussion;
type = 'discussion';
}
if (item.number !== 1989 && item.title.indexOf("Taylor's Version") === -1 && item.title.indexOf("THIS IS A TEST") === -1) {
return;
}
// Update the issue, pull_request, or discussion title to be "#{title} (Taylor's Version)"
if (type === 'issue'){
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: item.number,
title: `${item.title} (Taylor's Version)`
})
} else if (type === 'pull_request'){
github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: item.number,
title: `${item.title} (Taylor's Version)`
})
} else if (type === 'discussion'){
// Update the discussion title via the GraphQL API since REST seems unavailable
const query = `mutation {
updateDiscussion(input: {discussionId: "${item.id}", title: "${item.title} (Taylor's Version)"}) {
discussion {
title
}
}
}`;
github.graphql(query);
}