mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-06-05 22:43:43 +00:00
Auto merge on auto update.
This commit is contained in:
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user