mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-10-13 04:58:51 +00:00
The release, release-cgo and autoupdate workflows must run on a runner the caller chooses. Each workflow now takes a runner input. It accepts a label or a JSON object that selects a runner group. The workflow uses inputs.runner first. It then uses the SHARED_ACTIONS_RUNNER variable and falls back to ubuntu-latest. Callers that set nothing keep the old behaviour. Every job now has a timeout. Release and autoupdate runs use a concurrency group that never cancels a running job.
97 lines
2.9 KiB
YAML
97 lines
2.9 KiB
YAML
name: Go Autoupdate
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
go-version:
|
|
description: "Go version to use"
|
|
required: false
|
|
type: string
|
|
default: ">=1.24"
|
|
release-workflow:
|
|
description: "Release workflow file to trigger (e.g., release.yml)"
|
|
required: false
|
|
type: string
|
|
default: "release.yml"
|
|
lfs:
|
|
description: "Enable Git LFS checkout (for repos with large files)"
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
runner:
|
|
description: "Runner label, or JSON object such as {\"group\":\"ci\",\"labels\":[\"linux\"]} to select a runner group. Falls back to vars.SHARED_ACTIONS_RUNNER, then ubuntu-latest."
|
|
required: false
|
|
type: string
|
|
default: ""
|
|
|
|
concurrency:
|
|
group: autoupdate-${{ github.repository }}-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
autoupdate:
|
|
name: Update dependencies and test
|
|
runs-on: ${{ fromJSON(startsWith(inputs.runner || vars.SHARED_ACTIONS_RUNNER || 'ubuntu-latest', '{') && inputs.runner || vars.SHARED_ACTIONS_RUNNER || 'ubuntu-latest' || toJSON(inputs.runner || vars.SHARED_ACTIONS_RUNNER || 'ubuntu-latest')) }}
|
|
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
lfs: ${{ inputs.lfs }}
|
|
|
|
- name: Run workflow prepare script
|
|
shell: bash
|
|
run: |
|
|
if [ -f "./workflow-prepare.sh" ]; then
|
|
chmod +x ./workflow-prepare.sh
|
|
./workflow-prepare.sh
|
|
fi
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v6
|
|
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: 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: Create Pull Request
|
|
id: create-pr
|
|
if: steps.changes.outputs.changes_detected == 'true'
|
|
uses: peter-evans/create-pull-request@v8
|
|
with:
|
|
token: ${{ secrets.HOMEBREW_TAP_TOKEN || github.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.HOMEBREW_TAP_TOKEN || github.token }}
|