mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-06-11 23:19:19 +00:00
Auto merge on auto update.
This commit is contained in:
@@ -13,6 +13,10 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: "release.yml"
|
default: "release.yml"
|
||||||
|
secrets:
|
||||||
|
pat-token:
|
||||||
|
description: "Personal Access Token for creating PRs with verified commits"
|
||||||
|
required: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
autoupdate:
|
autoupdate:
|
||||||
@@ -39,21 +43,33 @@ jobs:
|
|||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: go test -race -cover ./...
|
run: go test -race -cover ./...
|
||||||
|
|
||||||
- name: Commit changes
|
- name: Check for changes
|
||||||
id: auto-commit
|
id: changes
|
||||||
uses: stefanzweifel/git-auto-commit-action@v5
|
run: |
|
||||||
with:
|
if git diff --quiet go.mod go.sum; then
|
||||||
commit_message: "Update go.mod and go.sum"
|
echo "changes_detected=false" >> $GITHUB_OUTPUT
|
||||||
file_pattern: "go.mod go.sum"
|
else
|
||||||
|
echo "changes_detected=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Trigger release workflow
|
- name: Create Pull Request
|
||||||
if: steps.auto-commit.outputs.changes_detected == 'true'
|
id: create-pr
|
||||||
uses: actions/github-script@v7
|
if: steps.changes.outputs.changes_detected == 'true'
|
||||||
|
uses: peter-evans/create-pull-request@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
token: ${{ secrets.pat-token }}
|
||||||
await github.rest.actions.createWorkflowDispatch({
|
commit-message: "Update go.mod and go.sum"
|
||||||
owner: context.repo.owner,
|
title: "Update Go dependencies"
|
||||||
repo: context.repo.repo,
|
body: |
|
||||||
workflow_id: '${{ inputs.release-workflow }}',
|
Automated dependency update.
|
||||||
ref: 'main'
|
|
||||||
})
|
- 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