Merge branch 'main' into fix-github-action
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 8bb2bf1..bece349 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -29,12 +29,21 @@
steps:
- name: Get current date
id: date
- run: echo "::set-output name=current_date::$(date +'%Y-%m-%d')"
+ run: echo "::set-output name=current_date::$(date +'%Y-%m-%d-%HH%MM%SS')"
+
+ - name: Sync fork
+ run: gh repo sync $REPOSITORY -b $BRANCH_NAME
+ env:
+ REPOSITORY: 'yoshi-code-bot/google-api-python-client'
+ BRANCH_NAME: 'refs/heads/main'
+ GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
- name: Check out main branch
uses: actions/checkout@v3
with:
ref: refs/heads/main
+ repository: 'yoshi-code-bot/google-api-python-client'
+ token: ${{secrets.YOSHI_CODE_BOT_TOKEN}}
- name: Create branch
run: |
@@ -68,7 +77,7 @@
working-directory: ./scripts
- name: Push changes
- run: git push -f --set-upstream origin update-discovery-artifacts-${{ steps.date.outputs.current_date }}
+ run: git push -u origin update-discovery-artifacts-${{ steps.date.outputs.current_date }}
- name: Prepare summary for PR Body
id: pr_body
@@ -83,43 +92,8 @@
working-directory: ./scripts
- name: Create PR
- uses: actions/github-script@v6.4.1
- with:
- github-token: ${{secrets.YOSHI_CODE_BOT_TOKEN}}
- script: |
- async function createPR () {
- const { owner, repo } = context.repo
- const branch = 'update-discovery-artifacts-${{ steps.date.outputs.current_date }}'
- let prBody = `${{ steps.pr_body.outputs.change_summary }}`
- const prTitle = 'chore: Update discovery artifacts'
- const pullRequests = await github.rest.pulls.list({
- owner: owner,
- repo: repo,
- head: `${owner}:${branch}`,
- state: 'open'
- })
-
- if (pullRequests.data.length === 1) {
- prNumber = pullRequests.data[0].number
- await github.rest.pulls.update({
- owner: owner,
- repo: repo,
- pull_number: prNumber,
- title: prTitle,
- body: prBody
- })
- console.log('Updated PR')
- } else {
- const createPrResult = await github.rest.pulls.create({
- owner: owner,
- repo: repo,
- base: 'main',
- head: `${owner}:${branch}`,
- title: prTitle,
- body: prBody
- })
- prNumber = createPrResult.data.number
- console.log('Created PR')
- }
- }
- createPR()
+ env:
+ GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
+ PR_TITLE: "chore: Update discovery artifacts"
+ run: |
+ gh pr create -R "googleapis/google-api-python-client" -B "main" --title "$PR_TITLE" --body "${{ steps.pr_body.outputs.change_summary }}"