2121 - name : Raise pull request
2222 uses : actions/github-script@0.4.0
2323 with :
24- debug : true
2524 github-token : ${{secrets.GITHUB_TOKEN}}
2625 script : |
2726 const { readFileSync } = require('fs');
@@ -30,42 +29,38 @@ jobs:
3029 const baseBranch = 'master';
3130 const branch = `update-dependencies-${new Date().toISOString().replace(/[T:]/g,'-').split('.')[0]}`;
3231
33- const latest = await github.git.getRef({
32+ const baseBranchRef = await github.git.getRef({
3433 ...context.repo,
3534 ref: `heads/${baseBranch}`
3635 });
37- console.log(latest) ;
36+ const parentSha = baseBranchRef.data.object.sha ;
3837
3938 const tree = await github.git.createTree({
4039 ...context.repo,
41- base_tree: latest.data.object.sha ,
40+ base_tree: parentSha ,
4241 tree: ['package.json', 'package-lock.json'].map(path => ({
4342 path,
4443 mode: '100644',
4544 content: readFileSync(resolve(process.cwd(), path), 'utf8')
4645 }))
4746 });
48- console.log(tree);
4947
5048 const commit = await github.git.createCommit({
5149 ...context.repo,
5250 message: 'Update dependencies',
5351 tree: tree.data.sha,
54- parents: [latest.data.object.sha]
55- })
56- console.log(commit);
52+ parents: [parentSha]
53+ });
5754
58- const push = await github.git.createRef({
55+ await github.git.createRef({
5956 ...context.repo,
6057 ref: `refs/heads/${branch}`,
6158 sha: commit.data.sha
62- })
63- console.log(push);
59+ });
6460
65- const pullRequest = await github.pulls.create({
61+ await github.pulls.create({
6662 ...context.repo,
6763 title: branch.replace(/-/g,' '),
6864 head: branch,
6965 base: baseBranch
7066 });
71- console.log(pullRequest);
0 commit comments