This GitHub Action checks if your go.mod
and go.sum
files are properly updated and optionally prevents indirect
dependency updates.
- Runs
go mod tidy
to check ifgo.mod
andgo.sum
files have any changes. If there are changes, the action fails. - If
prohibitIndirectDepUpdate
is set totrue
, the action will first remove indirect dependency blocks (excluding replace blocks) fromgo.mod
, then rungo mod tidy
, and check if thego.mod
andgo.sum
files have any changes compared to the initial state. If there are changes, the action fails.
To use this action in your project, follow these steps:
- Add a new workflow file or edit an existing one in your project's
.github/workflows
directory. For example, create or edit.github/workflows/go-mod-check.yml
. - Add the following content to the file:
name: Go Mod Check
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
go-mod-check:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run Go Mod Check Action
uses: Shoothzj/go-mod-check-action@main
with:
prohibitIndirectDepUpdate: 'true'
Now, the go-mod-check-action
will run on every push/pr to your project, ensuring that the go.mod
and go.sum
files
are properly updated and preventing indirect dependency updates if required.
You can configure the action using the following input parameters:
Parameter | Description | Required | Default |
---|---|---|---|
prohibitIndirectDepUpdate |
If set to true , the action will prohibit indirect dependency updates. |
No | false |
This project is licensed under the Apache 2.0 License.