@@ -29,12 +29,21 @@ jobs:
2929 steps :
3030 - name : Get current date
3131 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 }}
3340
3441 - name : Check out main branch
3542 uses : actions/checkout@v4
3643 with :
3744 ref : refs/heads/main
45+ repository : ' yoshi-code-bot/google-api-python-client'
46+ token : ${{secrets.YOSHI_CODE_BOT_TOKEN}}
3847
3948 - name : Create branch
4049 run : |
6877 working-directory : ./scripts
6978
7079 - 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 }}
7281
7382 - name : Prepare summary for PR Body
7483 id : pr_body
8392 working-directory : ./scripts
8493
8594 - 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