Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
uses: ./
with:
addHoldComment: "true"
status: "${{ job.status }}"
status: "${{ job.status }}"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ semantic-release-dry-run:
install-npm-check-updates:
npm install npm-check-updates

.PHONY: update-denendencies
update-denendencies: install-npm-check-updates
.PHONY: update-dependencies
update-dependencies: install-npm-check-updates
ncu -u
npm install
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ GitHub does not update the status of a commit when running workflow and therefor
* optional
* default: "true"

* addHoldComment: If true the action will add a comment to the pull request. This is useful if you use prow and you get PRs from forks, you can use `/hold` and `/hold cancel` instead of the status check since the token won't have permissions to do that.
* addHoldComment: If true the action will add a comment to the pull request. This is useful if you use prow, since prow won't detect the github actions, so you can use `/hold` and `/hold cancel` to avoid merging the PR before you want. __Important: this will be disabled for forks if `ignoreForks` is set to true, this is because the default github token won't have permissions to add comments if your PR comes from a fork__

* optional
* default: "false"
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ouzi-dev/commit-status-updater@v1.0.0
- uses: ouzi-dev/commit-status-updater@v1.0.4
```

### Action sets commit to error status without comment
Expand All @@ -97,7 +97,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ouzi-dev/commit-status-updater@v1.0.0
- uses: ouzi-dev/commit-status-updater@v1.0.4
with:
status: "error"
```
Expand All @@ -114,11 +114,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ouzi-dev/commit-status-updater@v1.0.0
- uses: ouzi-dev/commit-status-updater@v1.0.4
with:
addHoldComment: "true"
- if: always()
uses: ouzi-dev/commit-status-updater@v1.0.0
uses: ouzi-dev/commit-status-updater@v1.0.4
with:
addHoldComment: "true"
status: "${{ job.status }}"
Expand All @@ -136,7 +136,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ouzi-dev/commit-status-updater@v1.0.0
- uses: ouzi-dev/commit-status-updater@v1.0.4
with:
status: "pending"
addHoldComment: "true"
Expand All @@ -157,7 +157,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ouzi-dev/commit-status-updater@v1.0.0
- uses: ouzi-dev/commit-status-updater@v1.0.4
with:
status: "error"
url: http://myurl.io/
Expand All @@ -177,7 +177,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ouzi-dev/commit-status-updater@v1.0.0
- uses: ouzi-dev/commit-status-updater@v1.0.4
with:
token: "my_custom_token"
ignoreForks: "false"
Expand Down
17 changes: 17 additions & 0 deletions __test__/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ describe('runner tests', () => {
expect(mockIGithubHelper.addComment).toHaveBeenCalledTimes(0)
})

it('run does not set status or comment when it is a fork and add comment enabled', async () => {
const params = ({} as unknown) as IParams
params.token = 'bleh'
params.ignoreForks = true
params.addHoldComment = true
params.selectedComment = 'my comment'
mockInputsHelper.getInputs.mockReturnValue(params)
mockGithubHelper.CreateGithubHelper.mockReturnValue(mockIGithubHelper)
mockIGithubHelper.isFork.mockReturnValue(true)

await runner.run()

expect(mockUtils.validateEventType).toHaveBeenCalled()
expect(mockIGithubHelper.setStatus).toHaveBeenCalledTimes(0)
expect(mockIGithubHelper.addComment).toHaveBeenCalledTimes(0)
})

it('run sets status if ignore fork false', async () => {
const params = ({} as unknown) as IParams
params.token = 'bleh'
Expand Down
19 changes: 12 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1445,9 +1445,11 @@ function run() {
}
else {
yield ghHelper.setStatus(params);
}
if (params.addHoldComment) {
yield ghHelper.addComment(params.selectedComment);
// for now only add comments if it's not a fork or we explicitly say don't ignore forks
// we should have a token with permissions in the fork for this
if (params.addHoldComment) {
yield ghHelper.addComment(params.selectedComment);
}
}
}
catch (error) {
Expand Down Expand Up @@ -3555,9 +3557,9 @@ module.exports = safer
/***/ }),

/***/ 256:
/***/ (function() {
/***/ (function(module) {

eval("require")("iconv");
module.exports = eval("require")("iconv");


/***/ }),
Expand Down Expand Up @@ -28427,10 +28429,13 @@ class GithubHelper {
}
addComment(comment) {
return __awaiter(this, void 0, void 0, function* () {
// if we support forks, then we need to use the base, cause head will be the fork
const baseOwner = this.payload.pull_request.base.repo.owner.login;
const baseRepo = this.payload.pull_request.base.repo.name;
try {
yield this.octokit.issues.createComment({
owner: this.owner,
repo: this.repo,
owner: baseOwner,
repo: baseRepo,
issue_number: this.issueNumber,
body: comment
});
Expand Down
Loading