|
1 | | -import { exec, getExecOutput } from '@actions/exec' |
2 | 1 | import core from '@actions/core' |
| 2 | +import { exec, getExecOutput } from '@actions/exec' |
3 | 3 |
|
4 | | -const branch = process.env.GITHUB_BASE_REF |
| 4 | +async function main() { |
| 5 | + const branch = process.env.GITHUB_BASE_REF |
5 | 6 |
|
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 | + } |
7 | 12 |
|
8 | | -const { stdout } = await getExecOutput(`git diff origin/${branch} --name-only`) |
| 13 | + await exec(`git fetch origin ${branch}`) |
9 | 14 |
|
10 | | -const changedFiles = stdout.toString().trim().split('\n').filter(Boolean) |
| 15 | + const { stdout } = await getExecOutput(`git diff origin/${branch} --name-only`) |
11 | 16 |
|
12 | | -for (const changedFile of changedFiles) { |
13 | | - if (changedFile.startsWith('docs')) { |
14 | | - continue |
15 | | - } |
| 17 | + const changedFiles = stdout.toString().trim().split('\n').filter(Boolean) |
16 | 18 |
|
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')) { |
27 | 21 | continue |
28 | 22 | } |
| 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 |
29 | 40 | } |
30 | 41 |
|
31 | | - core.setOutput('only-doc-changes', false) |
32 | | - process.exit(0) |
| 42 | + core.setOutput('only-doc-changes', true) |
33 | 43 | } |
34 | 44 |
|
35 | | -core.setOutput('only-doc-changes', true) |
| 45 | +main() |
0 commit comments