Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional PULL_REQUEST_NUMBER input #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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,
Expand Down