@@ -29,12 +29,21 @@ jobs:
29
29
steps :
30
30
- name : Get current date
31
31
id : date
32
- run : echo "::set-output name=current_date::$(date +'%Y-%m-%d')"
32
+ run : echo "::set-output name=current_date::$(date +'%Y-%m-%d-%HH%MM%SS')"
33
+
34
+ - name : Sync fork
35
+ run : gh repo sync $REPOSITORY -b $BRANCH_NAME
36
+ env :
37
+ REPOSITORY : ' yoshi-code-bot/google-api-python-client'
38
+ BRANCH_NAME : ' refs/heads/main'
39
+ GITHUB_TOKEN : ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
33
40
34
41
- name : Check out main branch
35
42
uses : actions/checkout@v4
36
43
with :
37
44
ref : refs/heads/main
45
+ repository : ' yoshi-code-bot/google-api-python-client'
46
+ token : ${{secrets.YOSHI_CODE_BOT_TOKEN}}
38
47
39
48
- name : Create branch
40
49
run : |
68
77
working-directory : ./scripts
69
78
70
79
- name : Push changes
71
- run : git push -f --set-upstream origin update-discovery-artifacts-${{ steps.date.outputs.current_date }}
80
+ run : git push -u origin update-discovery-artifacts-${{ steps.date.outputs.current_date }}
72
81
73
82
- name : Prepare summary for PR Body
74
83
id : pr_body
83
92
working-directory : ./scripts
84
93
85
94
- name : Create PR
86
-
87
- with :
88
- github-token : ${{secrets.YOSHI_CODE_BOT_TOKEN}}
89
- script : |
90
- async function createPR () {
91
- const { owner, repo } = context.repo
92
- const branch = 'update-discovery-artifacts-${{ steps.date.outputs.current_date }}'
93
- let prBody = `${{ steps.pr_body.outputs.change_summary }}`
94
- const prTitle = 'chore: Update discovery artifacts'
95
- const pullRequests = await github.rest.pulls.list({
96
- owner: owner,
97
- repo: repo,
98
- head: `${owner}:${branch}`,
99
- state: 'open'
100
- })
101
-
102
- if (pullRequests.data.length === 1) {
103
- prNumber = pullRequests.data[0].number
104
- await github.rest.pulls.update({
105
- owner: owner,
106
- repo: repo,
107
- pull_number: prNumber,
108
- title: prTitle,
109
- body: prBody
110
- })
111
- console.log('Updated PR')
112
- } else {
113
- const createPrResult = await github.rest.pulls.create({
114
- owner: owner,
115
- repo: repo,
116
- base: 'main',
117
- head: `${owner}:${branch}`,
118
- title: prTitle,
119
- body: prBody
120
- })
121
- prNumber = createPrResult.data.number
122
- console.log('Created PR')
123
- }
124
- }
125
- createPR()
95
+ env :
96
+ GITHUB_TOKEN : ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
97
+ PR_TITLE : " chore: Update discovery artifacts"
98
+ run : |
99
+ gh pr create -R "googleapis/google-api-python-client" -B "main" --title "$PR_TITLE" --body "${{ steps.pr_body.outputs.change_summary }}"
0 commit comments