2023-03-28 21:29:27 +00:00
|
|
|
name: check-go-mod
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
runs-on:
|
|
|
|
description: An expression indicating which kind of runners to use.
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-03-30 16:57:11 +00:00
|
|
|
repository-name:
|
|
|
|
required: true
|
|
|
|
type: string
|
2024-01-08 22:18:41 +00:00
|
|
|
go-version:
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-03-30 16:57:11 +00:00
|
|
|
secrets:
|
|
|
|
elevated-github-token:
|
|
|
|
required: true
|
2023-03-28 21:29:27 +00:00
|
|
|
jobs:
|
|
|
|
check-go-mod:
|
|
|
|
runs-on: ${{ fromJSON(inputs.runs-on) }}
|
|
|
|
|
|
|
|
steps:
|
2023-07-19 23:56:50 +00:00
|
|
|
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2023-03-30 16:57:11 +00:00
|
|
|
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
|
|
|
|
- name: Setup Git
|
|
|
|
if: ${{ endsWith(inputs.repository-name, '-enterprise') }}
|
|
|
|
run: git config --global url."https://${{ secrets.elevated-github-token }}:@github.com".insteadOf "https://github.com"
|
2023-06-13 17:00:55 +00:00
|
|
|
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
|
2023-03-28 21:29:27 +00:00
|
|
|
with:
|
2024-01-08 22:18:41 +00:00
|
|
|
go-version: ${{ inputs.go-version }}
|
2023-11-27 21:28:35 +00:00
|
|
|
# Run on all go.mod (include submodules).
|
|
|
|
- run: make go-mod-tidy
|
2023-03-28 21:29:27 +00:00
|
|
|
- run: |
|
|
|
|
if [[ -n $(git status -s) ]]; then
|
|
|
|
echo "Git directory has changes"
|
|
|
|
git status -s
|
|
|
|
exit 1
|
|
|
|
fi
|