File tree Expand file tree Collapse file tree 5 files changed +2119
-59
lines changed Expand file tree Collapse file tree 5 files changed +2119
-59
lines changed Original file line number Diff line number Diff line change 1- const { promisify } = require ( 'util' )
21const getCommit = gh => async data => {
3- let commitData = null
42 const options = {
5- user : data . repo . namespace ,
3+ owner : data . repo . namespace ,
64 repo : data . repo . name
75 }
86
97 let action = 'compareCommits'
108 // github sends this in some instances: first commit on a new branch?
119 if ( ! data . build . before || data . build . before === '0000000000000000000000000000000000000000' ) {
12- options . sha = data . build . after
10+ options . ref = data . build . after
1311 action = 'getCommit'
1412 } else {
1513 options . base = data . build . before
1614 options . head = data . build . after
1715 }
1816
19- const comparison = await promisify ( gh . repos [ action ] ) ( options )
17+ const comparison = await gh . rest . repos [ action ] ( options )
2018 return comparison . files . map ( f => f . filename )
2119}
2220
Original file line number Diff line number Diff line change 1- const { promisify } = require ( 'util' )
21const yaml = require ( 'yaml' )
32const getParsedYaml = gh => async data => {
43 let contents = data . yaml
54 if ( ! contents ) {
65 const options = {
7- user : data . repo . namespace ,
6+ owner : data . repo . namespace ,
87 repo : data . repo . name ,
98 ref : data . build . ref ,
109 path : data . repo . config_path
1110 }
12- const file = await promisify ( gh . repos . getContent ) ( options )
11+ const file = gh . rest . repos . getContent ( options )
1312 if ( ! file . content ) {
1413 console . log ( 'GH Response:' , file )
1514 throw new Error ( 'Unexpected response from GitHub' )
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "body-parser" : " ^1.18.3" ,
1313 "express" : " ^4.16.4" ,
14- "github4" : " ^1.1.1" ,
1514 "globule" : " ^1.2.1" ,
1615 "http-signature" : " ^1.2.0" ,
16+ "octokit" : " ^1.0.5" ,
1717 "yaml" : " ^1.7.1"
1818 }
1919}
Original file line number Diff line number Diff line change 11const express = require ( 'express' )
22const bodyParser = require ( 'body-parser' )
3- const GhApi = require ( 'github4 ' )
3+ const { Octokit } = require ( '@octokit/rest ' )
44const yaml = require ( 'yaml' )
55const glob = require ( 'globule' )
66const createFilesChangedDeterminer = require ( './lib/files-changed-determiner' )
@@ -10,8 +10,9 @@ const isValidSig = require('./lib/signature-validator')
1010const githubToken = process . env . GITHUB_TOKEN
1111const sharedKey = process . env . PLUGIN_SECRET
1212
13- const gh = new GhApi ( { version : '3.0.0' } )
14- gh . authenticate ( { type : 'token' , token : githubToken } )
13+ const gh = new Octokit ( {
14+ auth : githubToken
15+ } )
1516
1617const determineFilesChanged = createFilesChangedDeterminer ( gh )
1718const getParsedYaml = createParsedYamlRetriever ( gh )
You can’t perform that action at this time.
0 commit comments