chore: use code-suggester in github action
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8bb2bf1..fe8ffbb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml
@@ -20,6 +20,10 @@ # * is a special character in YAML so you have to quote this string # Run this Github Action every Tuesday at 7 AM UTC - cron: '0 7 * * 2' + # For testing purposes + pull_request: + branches: + - main jobs: build: @@ -83,43 +87,17 @@ working-directory: ./scripts - name: Create PR - uses: actions/github-script@v6.4.1 + uses: googleapis/code-suggester@v4 + env: + ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} 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' - }) + command: pr + force: true + upstream_owner: googleapis + upstream_repo: google-api-python-client + description: ${{ steps.pr_body.outputs.change_summary }} + title: 'chore: Update discovery artifacts' + message: 'chore: Update discovery artifacts' + branch: 'update-discovery-artifacts-${{ steps.date.outputs.current_date }}' + git_dir: '.' - 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()