Skip to content

Commit b87abbb

Browse files
committed
chore: update docs action to handle push event
1 parent 525f8b5 commit b87abbb

1 file changed

Lines changed: 32 additions & 22 deletions

File tree

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
1-
import { exec, getExecOutput } from '@actions/exec'
21
import core from '@actions/core'
2+
import { exec, getExecOutput } from '@actions/exec'
33

4-
const branch = process.env.GITHUB_BASE_REF
4+
async function main() {
5+
const branch = process.env.GITHUB_BASE_REF
56

6-
await exec(`git fetch origin ${branch}`)
7+
// If there is no branch, we're not in a pull request
8+
if (!branch) {
9+
core.setOutput('only-doc-changes', false)
10+
return
11+
}
712

8-
const { stdout } = await getExecOutput(`git diff origin/${branch} --name-only`)
13+
await exec(`git fetch origin ${branch}`)
914

10-
const changedFiles = stdout.toString().trim().split('\n').filter(Boolean)
15+
const { stdout } = await getExecOutput(`git diff origin/${branch} --name-only`)
1116

12-
for (const changedFile of changedFiles) {
13-
if (changedFile.startsWith('docs')) {
14-
continue
15-
}
17+
const changedFiles = stdout.toString().trim().split('\n').filter(Boolean)
1618

17-
for (const fileToIgnore of [
18-
'CHANGELOG.md',
19-
'CODE_OF_CONDUCT.md',
20-
'CONTRIBUTING.md',
21-
'CONTRIBUTORS.md',
22-
'LICENSE',
23-
'README.md',
24-
'SECURITY.md',
25-
]) {
26-
if (changedFile === fileToIgnore) {
19+
for (const changedFile of changedFiles) {
20+
if (changedFile.startsWith('docs')) {
2721
continue
2822
}
23+
24+
for (const fileToIgnore of [
25+
'CHANGELOG.md',
26+
'CODE_OF_CONDUCT.md',
27+
'CONTRIBUTING.md',
28+
'CONTRIBUTORS.md',
29+
'LICENSE',
30+
'README.md',
31+
'SECURITY.md',
32+
]) {
33+
if (changedFile === fileToIgnore) {
34+
continue
35+
}
36+
}
37+
38+
core.setOutput('only-doc-changes', false)
39+
return
2940
}
3041

31-
core.setOutput('only-doc-changes', false)
32-
process.exit(0)
42+
core.setOutput('only-doc-changes', true)
3343
}
3444

35-
core.setOutput('only-doc-changes', true)
45+
main()

0 commit comments

Comments
 (0)