mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-06-27 05:24:01 +00:00
Add go autoupdate workflow
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
name: Go Autoupdate
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
go-version:
|
||||||
|
description: "Go version to use"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: ">=1.21"
|
||||||
|
release-workflow:
|
||||||
|
description: "Release workflow file to trigger (e.g., release.yml)"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: "release.yml"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
autoupdate:
|
||||||
|
name: Update dependencies and test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ inputs.go-version }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Update dependencies
|
||||||
|
run: |
|
||||||
|
go get -u ./...
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
- 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: Trigger release workflow
|
||||||
|
if: steps.auto-commit.outputs.changes_detected == 'true'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
await github.rest.actions.createWorkflowDispatch({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
workflow_id: '${{ inputs.release-workflow }}',
|
||||||
|
ref: 'main'
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user