@@ -12,19 +12,19 @@ const main = async () => {
12
12
core . info ( '[INFO] Usage https://github.com/githubocto/repo-visualizer#readme' )
13
13
14
14
core . startGroup ( 'Configuration' )
15
- const myToken = core . getInput ( 'github_token' ) ;
16
- const octokit = github . getOctokit ( myToken )
17
- const context = github . context ;
18
- const repo = context . repo ;
19
-
20
- // const username = 'repo-visualizer'
21
- // await exec('git', ['config', 'user.name', username])
22
- // await exec('git', [
23
- // 'config',
24
- // 'user.email',
25
- // // `${username}@users .noreply.github.com`,
26
-
27
- // ])
15
+ // const myToken = core.getInput('github_token');
16
+ // const octokit = github.getOctokit(myToken)
17
+ // const context = github.context;
18
+ // const repo = context.repo;
19
+
20
+ const username = 'repo-visualizer'
21
+ await exec ( 'git' , [ 'config' , 'user.name' , username ] )
22
+ await exec ( 'git' , [
23
+ 'config' ,
24
+ 'user.email' ,
25
+ // `${username}@users .noreply.github.com`,
26
+
27
+ ] )
28
28
29
29
core . endGroup ( )
30
30
@@ -35,31 +35,34 @@ const main = async () => {
35
35
36
36
const outputFile = core . getInput ( "output_file" ) || "./diagram.svg"
37
37
38
- // await fs.writeFileSync(outputFile, componentCodeString)
38
+ //
39
+
40
+ await fs . writeFileSync ( outputFile , componentCodeString )
39
41
40
42
41
43
// add outputFile to git
42
44
// await execWithOutput('git', ['add', outputFile])
43
45
44
- await octokit . repo . updateFile ( {
45
- owner : repo . owner . login ,
46
- repo : repo . name ,
47
- path : outputFile ,
48
- content : componentCodeString ,
49
- sha : context . sha ,
50
- message : 'Repo visualizer: updated diagram' ,
51
- branch : context . branch
52
- } )
53
- // await exec('git', ['add', outputFile])
54
- // const diff = await execWithOutput('git', ['status', '--porcelain', outputFile])
55
- // core.info(`diff: ${diff}`)
56
- // if (!diff) {
57
- // core.info('[INFO] No changes to the repo detected, exiting')
58
- // return
59
- // }
60
-
61
- // exec('git', ['commit', '-m', "Repo visualizer: updated diagram"])
62
- // await exec('git', ['push'])
46
+ // await octokit.rest.git.createCommit
47
+ // repo.updateFile({
48
+ // owner: repo.owner.login,
49
+ // repo: repo.name,
50
+ // path: outputFile,
51
+ // content: componentCodeString,
52
+ // sha: context.sha,
53
+ // message: 'Repo visualizer: updated diagram',
54
+ // branch: context.branch
55
+ // })
56
+ await exec ( 'git' , [ 'add' , outputFile ] )
57
+ const diff = await execWithOutput ( 'git' , [ 'status' , '--porcelain' , outputFile ] )
58
+ core . info ( `diff: ${ diff } ` )
59
+ if ( ! diff ) {
60
+ core . info ( '[INFO] No changes to the repo detected, exiting' )
61
+ return
62
+ }
63
+
64
+ exec ( 'git' , [ 'commit' , '-m' , "Repo visualizer: updated diagram" ] )
65
+ await exec ( 'git' , [ 'push' ] )
63
66
64
67
console . log ( "All set!" )
65
68
}
0 commit comments