From ffc4f9f50e041bf6574ff949e232e1af47947723 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Mon, 8 Dec 2025 01:09:43 +0000 Subject: [PATCH] Auto merge on auto update. --- .github/workflows/go-autoupdate.yaml | 48 ++++++++++++++++++---------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/.github/workflows/go-autoupdate.yaml b/.github/workflows/go-autoupdate.yaml index 3de8d6b..122957a 100644 --- a/.github/workflows/go-autoupdate.yaml +++ b/.github/workflows/go-autoupdate.yaml @@ -13,6 +13,10 @@ on: required: false type: string default: "release.yml" + secrets: + pat-token: + description: "Personal Access Token for creating PRs with verified commits" + required: true jobs: autoupdate: @@ -39,21 +43,33 @@ jobs: - name: Run tests run: go test -race -cover ./... - - name: Commit changes - id: auto-commit - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "Update go.mod and go.sum" - file_pattern: "go.mod go.sum" + - name: Check for changes + id: changes + run: | + if git diff --quiet go.mod go.sum; then + echo "changes_detected=false" >> $GITHUB_OUTPUT + else + echo "changes_detected=true" >> $GITHUB_OUTPUT + fi - - name: Trigger release workflow - if: steps.auto-commit.outputs.changes_detected == 'true' - uses: actions/github-script@v7 + - name: Create Pull Request + id: create-pr + if: steps.changes.outputs.changes_detected == 'true' + uses: peter-evans/create-pull-request@v7 with: - script: | - await github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: '${{ inputs.release-workflow }}', - ref: 'main' - }) + token: ${{ secrets.pat-token }} + commit-message: "Update go.mod and go.sum" + title: "Update Go dependencies" + body: | + Automated dependency update. + + - Updated `go.mod` and `go.sum` via `go get -u ./...` + - All tests passed + branch: auto-update-go-deps + delete-branch: true + + - name: Merge PR + if: steps.create-pr.outputs.pull-request-number + run: gh pr merge --squash --delete-branch --admin "${{ steps.create-pr.outputs.pull-request-number }}" + env: + GH_TOKEN: ${{ secrets.pat-token }}