generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from sarthak-saxena/fix/running-action-on-merge…
…-branch Fix: Running on a branch fails as octokit not able to comment
- Loading branch information
Showing
2 changed files
with
36 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1397,22 +1397,6 @@ async function run() { | |
const octokit = new github.GitHub(token); | ||
// --------------- End octokit initialization --------------- | ||
|
||
// --------------- Checkout code --------------- // | ||
// console.log("Checkout code"); | ||
// | ||
// await exec.exec( | ||
// `git clone [email protected]:${github.context.repo.owner}/${ | ||
// github.context.repo.repo | ||
// }` | ||
// ); | ||
// | ||
// const refBranch = github.context.ref; | ||
// console.log("ref", refBranch); | ||
// const branch = refBranch.split("refs/heads/")[1]; | ||
// await exec.exec(`git checkout ${branch}`); | ||
// | ||
// End --------------- Checkout code --------------- // | ||
|
||
// --------------- Build repo --------------- | ||
const bootstrap = core.getInput("bootstrap"), | ||
build_command = core.getInput("build_command"), | ||
|
@@ -1442,9 +1426,8 @@ async function run() { | |
}; | ||
await exec.exec(`du ${dist_path}`, null, outputOptions); | ||
core.setOutput("size", sizeCalOutput); | ||
|
||
const context = github.context, | ||
pull_request_number = context.payload.pull_request.number; | ||
pull_request = context.payload.pull_request; | ||
|
||
const arrayOutput = sizeCalOutput.split("\n"); | ||
let result = "Bundled size for the package is listed below: \n \n"; | ||
|
@@ -1455,12 +1438,23 @@ async function run() { | |
} | ||
}); | ||
|
||
octokit.issues.createComment( | ||
Object.assign(Object.assign({}, context.repo), { | ||
issue_number: pull_request_number, | ||
body: result | ||
}) | ||
); | ||
if (pull_request) { | ||
// on pull request commit push add comment to pull request | ||
octokit.issues.createComment( | ||
Object.assign(Object.assign({}, context.repo), { | ||
issue_number: pull_request.number, | ||
body: result | ||
}) | ||
); | ||
} else { | ||
// on commit push add comment to commit | ||
octokit.repos.createCommitComment( | ||
Object.assign(Object.assign({}, context.repo), { | ||
commit_sha: github.context.sha, | ||
body: result | ||
}) | ||
); | ||
} | ||
|
||
// --------------- End Comment repo size --------------- | ||
} catch (error) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters