Skip to content

Make it Taylor's Version #9

Make it Taylor's Version

Make it Taylor's Version #9

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);
}