@@ -13,12 +13,12 @@ const ignoredFiles = ['package-lock.json', 'pnpm-lock.yaml', 'yarn.lock']
13
13
14
14
async function run ( ) {
15
15
// Try to extract changeset data from the workflow context.
16
- if ( process . env . DEBUG ) logger . debug ( 'Context' , github . context )
17
- let { type, name, summary } = github . context . payload . inputs || { }
16
+ logger . debug ( 'Context' , github . context )
17
+ let { type, name, summary, token } = github . context . payload . inputs || { }
18
18
19
19
// Try to extract changeset data from the pull request label or workflow
20
20
// input.
21
- const labels = github . context . payload ?. pull_request ?. labels || [ ]
21
+ const { labels = [ ] , base , head } = github . context . payload ?. pull_request || { }
22
22
if ( ! type ) {
23
23
for ( const label of labels ) {
24
24
const [ ns , t ] = label . name . split ( '.' )
@@ -36,17 +36,24 @@ async function run () {
36
36
if ( name ) {
37
37
releases . push ( { name, type } )
38
38
} else {
39
- const { stdout } = await execa (
40
- 'git' ,
41
- [ 'diff-tree' , '--no-commit-id' , '--name-only' , '-r' , 'HEAD' , '--' ]
42
- )
43
- for ( const file of stdout . split ( '\n' ) ) {
39
+ // Get the list of changed files from GitHub.
40
+ const octokit = github . getOctokit ( token )
41
+ const res = await octokit . repos . compareCommits ( {
42
+ base : base . sha ,
43
+ head : head . sha ,
44
+ owner : github . context . repo . owner ,
45
+ repo : github . context . repo . repo
46
+ } )
47
+
48
+ logger . info ( 'Files' , res . data . files )
49
+
50
+ for ( const file of res . data . files ) {
44
51
if ( ! ignoredFiles . includes ( file ) ) {
45
52
const cwd = path . resolve ( path . dirname ( file ) )
46
53
const { packageJson, ...pkg } = await readPackageUpAsync ( { cwd } )
47
54
const hasPackage = releases . some ( r => r . name === packageJson . name )
48
55
if ( ! hasPackage ) releases . push ( { name : packageJson . name , type } )
49
- logger . info ( 'Git change found ', { file, ...pkg , cwd, hasPackage } )
56
+ logger . debug ( 'File ', { file, ...pkg , cwd, hasPackage } )
50
57
}
51
58
}
52
59
}
0 commit comments