diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index f1a23b15434..1299c13d272 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -3,6 +3,8 @@ on: pull_request jobs: auto-generate: + permissions: + contents: write runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -10,16 +12,21 @@ jobs: - uses: actions/setup-go@v3 with: go-version: '1.22' + + - name: make generate + run: make generate - - name: commit and push generated changes + - name: Checkout PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh pr checkout ${{ github.event.pull_request.number }} + + - name: Commit and push changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - make generate - if [ -n "$(git status --porcelain)" ]; then - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "chore: auto-generate" - git push origin HEAD:${{ github.head_ref }} - else - echo "no changes to commit and push" - fi \ No newline at end of file + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "chore: auto-generate" + git push \ No newline at end of file