From b03be403ea86f79077ea9cc0b835c3295faa12dd Mon Sep 17 00:00:00 2001 From: Vladimir Yumatov Date: Thu, 24 Mar 2022 15:45:41 +0300 Subject: [PATCH] Add optional PULL_REQUEST_NUMBER input --- action.yml | 4 ++++ index.js | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/action.yml b/action.yml index 5dafd37..4d3ace1 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,10 @@ inputs: CID_VERSION: # id of input description: "CID version (0 or 1)" required: true + PULL_REQUEST_NUMBER: + description: Pull request id in case it does not exist in the context by default + required: false + default: "0" GITHUB_TOKEN: description: "When supplied the action will leave a comment" default: ${{ github.token }} diff --git a/index.js b/index.js index 739ce17..3e09e63 100644 --- a/index.js +++ b/index.js @@ -89,6 +89,7 @@ cleanupAndPin().then(async (hash) => { } core.setOutput("uri", uri); const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN"); + const PR_NUM = Number(core.getInput("PULL_REQUEST_NUMBER")); if (GITHUB_TOKEN) { const octokit = github.getOctokit(GITHUB_TOKEN); if (github.context.eventName == "pull_request") { @@ -97,6 +98,13 @@ cleanupAndPin().then(async (hash) => { issue_number: context.payload.pull_request.number, body: `- Ipfs hash: ${hash}\n- Ipfs preview link: ${uri}`, }); + } else + if (PR_NUM != 0) { + await octokit.rest.issues.createComment({ + ...context.repo, + issue_number: PR_NUM, + body: `- Ipfs hash: ${hash}\n- Ipfs preview link: ${uri}`, + }); } else { await octokit.rest.repos.createCommitComment({ ...context.repo,