Skip to content

Commit

Permalink
revert: ⏪
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustav-Eikaas committed Dec 20, 2023
1 parent f7b5350 commit d77bc79
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
1 change: 0 additions & 1 deletion .github/helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@octokit/graphql": "^7.0.2",
"commander": "^11.1.0",
"markdown-table": "^3.0.3",
"tsx": "^4.6.2"
Expand Down
37 changes: 14 additions & 23 deletions .github/helpers/src/issue-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { Command } from 'commander';
import { getOctokit, context } from '@actions/github';
import { setSecret } from '@actions/core';

const program = new Command();
type Octo = ReturnType<typeof getOctokit>;
Expand Down Expand Up @@ -37,38 +36,30 @@ program
throw new Error('Missing pr number');
}

setSecret(args.token);

const client = getOctokit(args.token);
checkIssues(client, parseInt(args.pr), args.token);
checkIssues(client, args.pr);
});

await program.parseAsync();

async function checkIssues(client: Octo, pr: number, token: string) {
const pullRequests = await client.graphql({
query: `query($owner: String!, $name: String!, $number: Int!) {
repository (owner: $owner, name: $name){
pullRequest (number: $number) {
closingIssuesReferences (first: 1){
totalCount
}
async function checkIssues(client: Octo, pr: number) {
const pullRequests = await client.graphql(
`query {
repository (owner: "${context.repo.owner}", name: "${context.repo.repo}"){
pullRequest (number: ${pr}) {
closingIssuesReferences (first: 1){
totalCount
}
}
}
`,
owner: context.repo.owner,
name: context.repo.repo,
number: pr,
headers: {
authorization: token,
},
});
}
}
`
.replaceAll('\n', '')
.trim()
);

const linkedIssues: number = (pullRequests as any).repository.pullRequest.closingIssuesReferences.totalCount;

console.log(JSON.stringify(pullRequests));

if (linkedIssues === 0) {
const comment = await client.rest.issues.createComment({
issue_number: pr,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-issue-check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Verify linked issue

permissions: write-all
# This action works with pull requests and pushes
on:
workflow_dispatch:

Expand Down

0 comments on commit d77bc79

Please sign in to comment.