From b66dfa52d135f329d86c83207cb7d4286f6ea2f6 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Fri, 25 Apr 2025 23:18:08 +0900 Subject: [PATCH 01/22] add test workflow --- .github/workflows/test.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..61880c9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,20 @@ +name: TEST + +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm install + - run: npm run build + - run: node dist/index.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b505bff72ac89f08a4f32e7312d34d905a6a0289 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Fri, 25 Apr 2025 23:38:24 +0900 Subject: [PATCH 02/22] handle empty case --- src/index.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6eb18a1..4be043b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,17 +23,20 @@ const workflow_runs = actions.workflow_runs.filter((action) => { action.status === "completed" ); }); +if (workflow_runs.length === 0) { + console.log("No workflow runs found for this pull request."); +} else { + const latest = workflow_runs.reduce((latest, action) => { + if (!latest) return action; + return new Date(action.created_at) > new Date(latest.created_at) + ? action + : latest; + }); -const latest = workflow_runs.reduce((latest, action) => { - if (!latest) return action; - return new Date(action.created_at) > new Date(latest.created_at) - ? action - : latest; -}); - -octokit.rest.issues.createComment({ - owner, - repo, - issue_number: pull_request_number, - body: `The latest workflow run for this pull request is [#${latest.run_number}](${latest.html_url})`, -}); + octokit.rest.issues.createComment({ + owner, + repo, + issue_number: pull_request_number, + body: `The latest workflow run for this pull request is [#${latest.run_number}](${latest.html_url})`, + }); +} From 50a6ac2d91448d8fc9b807e3753cd70adfc3198e Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Fri, 25 Apr 2025 23:47:24 +0900 Subject: [PATCH 03/22] change predicate --- src/index.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4be043b..e2ff466 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,13 +16,10 @@ const { data: actions } = await octokit.rest.actions.listWorkflowRunsForRepo({ repo, }); -const workflow_runs = actions.workflow_runs.filter((action) => { - return ( - action.head_branch === pullRequest.head.ref && - action.head_sha === pullRequest.head.sha && - action.status === "completed" - ); -}); +const workflow_runs = actions.workflow_runs.filter( + (action) => action.status === "completed" +); + if (workflow_runs.length === 0) { console.log("No workflow runs found for this pull request."); } else { From 80ac28713e50d7d079db9f27302b70251a7574cc Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Fri, 25 Apr 2025 23:51:10 +0900 Subject: [PATCH 04/22] run on push --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61880c9..5c6e2b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,9 @@ name: TEST on: + push: + branches: + - main pull_request: branches: - main From 6bbe320e82c356cc8f42873420f951a4d0ab57bc Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Fri, 25 Apr 2025 23:53:07 +0900 Subject: [PATCH 05/22] comment out unused variable --- src/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index e2ff466..07fa21f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,11 +5,11 @@ const octokit = new Octokit(); const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/")!; const pull_request_number = parseInt(process.env.GITHUB_REF?.split("/")[2]!); -const { data: pullRequest } = await octokit.rest.pulls.get({ - owner, - repo, - pull_number: pull_request_number, -}); +// const { data: pullRequest } = await octokit.rest.pulls.get({ +// owner, +// repo, +// pull_number: pull_request_number, +// }); const { data: actions } = await octokit.rest.actions.listWorkflowRunsForRepo({ owner, From 2494188693f5cc3fe3b0cfe4c871849044da05ab Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Fri, 25 Apr 2025 23:57:09 +0900 Subject: [PATCH 06/22] narrow down --- src/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 07fa21f..9e7f8ce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,11 +5,11 @@ const octokit = new Octokit(); const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/")!; const pull_request_number = parseInt(process.env.GITHUB_REF?.split("/")[2]!); -// const { data: pullRequest } = await octokit.rest.pulls.get({ -// owner, -// repo, -// pull_number: pull_request_number, -// }); +const { data: pullRequest } = await octokit.rest.pulls.get({ + owner, + repo, + pull_number: pull_request_number, +}); const { data: actions } = await octokit.rest.actions.listWorkflowRunsForRepo({ owner, @@ -17,7 +17,8 @@ const { data: actions } = await octokit.rest.actions.listWorkflowRunsForRepo({ }); const workflow_runs = actions.workflow_runs.filter( - (action) => action.status === "completed" + (action) => + action.head_branch === pullRequest.head.ref && action.status === "completed" ); if (workflow_runs.length === 0) { From 6b2f9ad57bb39edd66d11945d4fe1afda1b99dd1 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 00:04:06 +0900 Subject: [PATCH 07/22] add C++ source and compile job --- .github/workflows/test.yml | 9 +++++++++ source.cpp | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 source.cpp diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c6e2b3..bd1d30a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,16 @@ on: - main jobs: + compile: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: g++ -Wall -Wextra -o test source.cpp + - run: ./test + test: + needs: + - compile runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/source.cpp b/source.cpp new file mode 100644 index 0000000..2ad3499 --- /dev/null +++ b/source.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + int unused_variable = 42; + std::cout << "Hello, World!" << std::endl; +} From 3a8218529eeb0be88bfd30d60d6c02dc80bdcce4 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 00:14:02 +0900 Subject: [PATCH 08/22] pass compiation outputs --- .github/workflows/test.yml | 8 +++++++- src/index.ts | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd1d30a..47f5b1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,15 +11,20 @@ on: jobs: compile: runs-on: ubuntu-latest + outputs: + compilation_outputs: ${{ steps.compile.outputs }} steps: - uses: actions/checkout@v4 - - run: g++ -Wall -Wextra -o test source.cpp + - run: g++ -Wall -Wextra -o test source.cpp 2 > $GITHUB_OUTPUT + id: compile - run: ./test test: needs: - compile runs-on: ubuntu-latest + outputs: + compilation_outputs: ${{ needs.compile.outputs.compilation_outputs }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -30,3 +35,4 @@ jobs: - run: node dist/index.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMPILATION_OUTPUTS: ${{ needs.compile.outputs.compilation_outputs }} diff --git a/src/index.ts b/src/index.ts index 9e7f8ce..4b61cec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ const octokit = new Octokit(); const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/")!; const pull_request_number = parseInt(process.env.GITHUB_REF?.split("/")[2]!); +const compilation_output = process.env.COMPILATION_OUTPUT!; const { data: pullRequest } = await octokit.rest.pulls.get({ owner, @@ -35,6 +36,6 @@ if (workflow_runs.length === 0) { owner, repo, issue_number: pull_request_number, - body: `The latest workflow run for this pull request is [#${latest.run_number}](${latest.html_url})`, + body: `The latest workflow run for this pull request is [#${latest.run_number}](${latest.html_url}), and the compilation output is:\n\n\`\`\`\n${compilation_output}\n\`\`\``, }); } From 384f6649e84e5748c5e5d498c5518b4b360445df Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 00:14:42 +0900 Subject: [PATCH 09/22] fix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 47f5b1b..ef8808e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: compilation_outputs: ${{ steps.compile.outputs }} steps: - uses: actions/checkout@v4 - - run: g++ -Wall -Wextra -o test source.cpp 2 > $GITHUB_OUTPUT + - run: g++ -Wall -Wextra -o test source.cpp 2> $GITHUB_OUTPUT id: compile - run: ./test From dab197e449061b6469584fda0f3c56ce5bf4c5a1 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 00:17:17 +0900 Subject: [PATCH 10/22] fix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ef8808e..9a943f5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: compilation_outputs: ${{ steps.compile.outputs }} steps: - uses: actions/checkout@v4 - - run: g++ -Wall -Wextra -o test source.cpp 2> $GITHUB_OUTPUT + - run: g++ -Wall -Wextra -o test source.cpp 2>&1 >> $GITHUB_OUTPUT id: compile - run: ./test From 89cd63b8bfca0efc4aed4bf7b81c5e2a8e16c327 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 00:21:57 +0900 Subject: [PATCH 11/22] fix --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a943f5..fd1521c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,8 +23,6 @@ jobs: needs: - compile runs-on: ubuntu-latest - outputs: - compilation_outputs: ${{ needs.compile.outputs.compilation_outputs }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From defffdc19ada069ce0a7bce77ff7c985ea02a05d Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 00:23:50 +0900 Subject: [PATCH 12/22] more warnings --- source.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source.cpp b/source.cpp index 2ad3499..12b9916 100644 --- a/source.cpp +++ b/source.cpp @@ -1,6 +1,9 @@ #include +[[nodiscard]] int func() { return 42; } + int main() { int unused_variable = 42; + func(); std::cout << "Hello, World!" << std::endl; } From 527cabdfba1eb1215433a948c79106ac592a7a27 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 00:26:34 +0900 Subject: [PATCH 13/22] map --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd1521c..67d84d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,10 +12,10 @@ jobs: compile: runs-on: ubuntu-latest outputs: - compilation_outputs: ${{ steps.compile.outputs }} + compilation_outputs: ${{ steps.compile.outputs.log }} steps: - uses: actions/checkout@v4 - - run: g++ -Wall -Wextra -o test source.cpp 2>&1 >> $GITHUB_OUTPUT + - run: echo "log=`g++ -Wall -Wextra -o test source.cpp 2>&1`"" >> $GITHUB_OUTPUT id: compile - run: ./test From 7e56872144d212943e829c85d2d11bf13ea29fd5 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 00:27:10 +0900 Subject: [PATCH 14/22] remove quote --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67d84d5..1d9010f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: compilation_outputs: ${{ steps.compile.outputs.log }} steps: - uses: actions/checkout@v4 - - run: echo "log=`g++ -Wall -Wextra -o test source.cpp 2>&1`"" >> $GITHUB_OUTPUT + - run: echo "log=`g++ -Wall -Wextra -o test source.cpp 2>&1`" >> $GITHUB_OUTPUT id: compile - run: ./test From 6f845b91d0a2e521d542349b4b0bc7b5816e8c97 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 00:38:13 +0900 Subject: [PATCH 15/22] use github script --- .github/workflows/test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1d9010f..9b95c80 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,10 +12,13 @@ jobs: compile: runs-on: ubuntu-latest outputs: - compilation_outputs: ${{ steps.compile.outputs.log }} + compilation_outputs: ${{ steps.compile.outputs.result }} steps: - uses: actions/checkout@v4 - - run: echo "log=`g++ -Wall -Wextra -o test source.cpp 2>&1`" >> $GITHUB_OUTPUT + - uses: actions/github-script@v6 + with: + script: | + return require('child_process').spawnSync('g++ -Wall -o test source.cpp').stderr id: compile - run: ./test From fd1eae11ab61dcfcfa1f0c9edbd52a82c667db4f Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 01:19:56 +0900 Subject: [PATCH 16/22] fix? --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9b95c80..681d174 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,10 @@ jobs: compilation_outputs: ${{ steps.compile.outputs.result }} steps: - uses: actions/checkout@v4 - - uses: actions/github-script@v6 - with: - script: | - return require('child_process').spawnSync('g++ -Wall -o test source.cpp').stderr + - run: | + echo "result=<> $GITHUB_OUTPUT + g++ -o test source.cpp 2>&1 >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT id: compile - run: ./test From 8f13bd34fe1364df7e496e7f4c99ff43b443ead0 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 01:28:02 +0900 Subject: [PATCH 17/22] use artifacts --- .github/workflows/test.yml | 15 ++++++++------- src/index.ts | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 681d174..df90800 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,15 +11,14 @@ on: jobs: compile: runs-on: ubuntu-latest - outputs: - compilation_outputs: ${{ steps.compile.outputs.result }} steps: - uses: actions/checkout@v4 - run: | - echo "result=<> $GITHUB_OUTPUT - g++ -o test source.cpp 2>&1 >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - id: compile + g++ -o test source.cpp 2>&1 > compilation.log + - uses: actions/upload-artifact@v3 + with: + name: compilation_log + path: compilation.log - run: ./test test: @@ -33,7 +32,9 @@ jobs: node-version: 20 - run: npm install - run: npm run build + - uses: actions/download-artifact@v3 + with: + name: compilation_log - run: node dist/index.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMPILATION_OUTPUTS: ${{ needs.compile.outputs.compilation_outputs }} diff --git a/src/index.ts b/src/index.ts index 4b61cec..7a7cffb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ import { Octokit } from "@octokit/action"; +import { readFileSync } from "fs"; const octokit = new Octokit(); const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/")!; const pull_request_number = parseInt(process.env.GITHUB_REF?.split("/")[2]!); -const compilation_output = process.env.COMPILATION_OUTPUT!; - +const compilation_output = readFileSync("compilation.log"); const { data: pullRequest } = await octokit.rest.pulls.get({ owner, repo, From 6bdcd24f831b0a1ebb0d3d67a808235d5c559776 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 01:30:59 +0900 Subject: [PATCH 18/22] update to v4 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index df90800..1bca075 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - run: | g++ -o test source.cpp 2>&1 > compilation.log - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: compilation_log path: compilation.log @@ -32,7 +32,7 @@ jobs: node-version: 20 - run: npm install - run: npm run build - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: compilation_log - run: node dist/index.js From 149e95ad92d1e9f31bee964e06846ce72be48f98 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 01:33:01 +0900 Subject: [PATCH 19/22] add warning option --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1bca075..af62b2c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - g++ -o test source.cpp 2>&1 > compilation.log + g++ -Wall -Wextra -o test source.cpp 2>&1 > compilation.log - uses: actions/upload-artifact@v4 with: name: compilation_log From 78ca21f6efc3c2f35841df90bce52b470e569026 Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 01:36:12 +0900 Subject: [PATCH 20/22] properly log outputs --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af62b2c..a8567d7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - g++ -Wall -Wextra -o test source.cpp 2>&1 > compilation.log + g++ -Wall -Wextra -o test source.cpp > compilation.log 2>&1 - uses: actions/upload-artifact@v4 with: name: compilation_log From f357b0b866f746907f4b8ed215cd24a75f08e98c Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 01:37:08 +0900 Subject: [PATCH 21/22] remove unneeded code --- src/index.ts | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7a7cffb..33b6b78 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,36 +6,10 @@ const octokit = new Octokit(); const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/")!; const pull_request_number = parseInt(process.env.GITHUB_REF?.split("/")[2]!); const compilation_output = readFileSync("compilation.log"); -const { data: pullRequest } = await octokit.rest.pulls.get({ - owner, - repo, - pull_number: pull_request_number, -}); -const { data: actions } = await octokit.rest.actions.listWorkflowRunsForRepo({ +octokit.rest.issues.createComment({ owner, repo, + issue_number: pull_request_number, + body: `compilation output is:\n\n\`\`\`\n${compilation_output}\n\`\`\``, }); - -const workflow_runs = actions.workflow_runs.filter( - (action) => - action.head_branch === pullRequest.head.ref && action.status === "completed" -); - -if (workflow_runs.length === 0) { - console.log("No workflow runs found for this pull request."); -} else { - const latest = workflow_runs.reduce((latest, action) => { - if (!latest) return action; - return new Date(action.created_at) > new Date(latest.created_at) - ? action - : latest; - }); - - octokit.rest.issues.createComment({ - owner, - repo, - issue_number: pull_request_number, - body: `The latest workflow run for this pull request is [#${latest.run_number}](${latest.html_url}), and the compilation output is:\n\n\`\`\`\n${compilation_output}\n\`\`\``, - }); -} From a265a1af0cf150b0f16be2a1bbbc3709686abaca Mon Sep 17 00:00:00 2001 From: yaito3014 Date: Sat, 26 Apr 2025 01:39:43 +0900 Subject: [PATCH 22/22] detect whether PR or not --- src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 33b6b78..b54089f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,12 @@ import { Octokit } from "@octokit/action"; import { readFileSync } from "fs"; +// if the action is triggered by not a pull request, exit +if (!process.env.GITHUB_REF?.startsWith("refs/pull/")) { + console.log("Not a pull request, exiting."); + process.exit(0); +} + const octokit = new Octokit(); const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/")!;