amd 55 current 2024-10-21 18:56:00 24.11.20241014.b36c6a9 6.6.56 … #351
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go Mod Tidy and Commit | |
on: | |
push: | |
branches: [main] | |
paths-ignore: | |
- '**.md' # Ignore markdown files changes | |
jobs: | |
dump_contexts_to_log: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: Dump job context | |
env: | |
JOB_CONTEXT: ${{ toJson(job) }} | |
run: echo "$JOB_CONTEXT" | |
- name: Dump steps context | |
env: | |
STEPS_CONTEXT: ${{ toJson(steps) }} | |
run: echo "$STEPS_CONTEXT" | |
- name: Dump runner context | |
env: | |
RUNNER_CONTEXT: ${{ toJson(runner) }} | |
run: echo "$RUNNER_CONTEXT" | |
- name: Dump strategy context | |
env: | |
STRATEGY_CONTEXT: ${{ toJson(strategy) }} | |
run: echo "$STRATEGY_CONTEXT" | |
- name: Dump matrix context | |
env: | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} | |
run: echo "$MATRIX_CONTEXT" | |
tidy: | |
name: ${{ matrix.working-directory }} tidy | |
strategy: | |
matrix: | |
include: [ { working-directory: "." } ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Dump job context | |
env: | |
JOB_CONTEXT: ${{ toJson(job) }} | |
run: echo "$JOB_CONTEXT" | |
- name: Dump strategy context | |
env: | |
STRATEGY_CONTEXT: ${{ toJson(strategy) }} | |
run: echo "$STRATEGY_CONTEXT" | |
- name: Dump matrix context | |
env: | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} | |
run: echo "$MATRIX_CONTEXT" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: "${{ matrix.working-directory }}/go.work" | |
check-latest: true | |
cache-dependency-path: "${{ matrix.working-directory }}/go.work.sum" | |
- name: Tidy Go modules in multiple directories | |
run: | | |
set -ex -o pipefail | |
dirs=("src/graph") | |
for dir in "${dirs[@]}"; do | |
if [[ -d "$dir" && -f "$dir/go.mod" ]]; then | |
echo "Running go mod tidy && go generate in $dir" | |
(cd "$dir" && go mod tidy -compat=1.17 && go generate ./...) | |
else | |
echo "Skipping $dir as it does not contain a go.mod file." | |
exit 1 | |
fi | |
done | |
- name: Auto commit changes | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: 'Maintain: Update go.mod and generated files' | |
branch: ${{ github.head_ref }} |