Skip to content

Commit 4faab38

Browse files
committed
fix: add ability to override commit sha
1 parent 02f8d89 commit 4faab38

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ If there is a coverage badge in the README file, you can add 2nd status check. T
109109

110110
![Coverage diff](images/coverage-diff.png)
111111

112+
### Pull requests
113+
114+
When setting a status on a GitHub pull request, you need to use SHA of the merged commit. You can pass it as `GH_SHA` environment variable.
115+
116+
```yaml
117+
- name: Ensure coverage has not dropped 📈
118+
run: npx set-gh-status --check-against-readme
119+
env:
120+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
GH_SHA: ${{ github.event.after }}
122+
```
123+
112124
## Debug
113125

114126
To see verbose log messages, run with `DEBUG=check-code-coverage` environment variable

bin/set-gh-status.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ const options = {
124124
const envOptions = {
125125
token: process.env.GITHUB_TOKEN,
126126
repository: process.env.GITHUB_REPOSITORY,
127-
sha: process.env.GITHUB_SHA
127+
// allow overriding the commit SHA, useful in pull requests
128+
// where we want a merged commit SHA from GH event
129+
sha: process.env.GH_SHA || process.env.GITHUB_SHA
128130
}
129131
setGitHubCommitStatus(options, envOptions).catch(e => {
130132
console.error(e)

0 commit comments

Comments
 (0)