Merge pull request #335 from robinje/dependabot/pip/requirements/debu… #781
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 Format and Check | |
on: | |
push: | |
branches: [develop, qa, prod] | |
pull_request: | |
branches: "**" | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
format-and-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.23 | |
- name: Install govulncheck | |
run: go install golang.org/x/vuln/cmd/govulncheck@latest | |
- name: Configure Git | |
run: | | |
git fetch -q | |
git checkout ${{github.head_ref}} --progress | |
git config --global user.name 'Dark Relics Automatic' | |
git config --global user.email '[email protected]' | |
git pull | |
- name: Format and check code | |
run: | | |
echo "Processing directory" | |
cd server | |
go mod download | |
go fmt ./... | |
go mod tidy | |
go mod verify | |
go vet ./... | |
govulncheck ./... | |
cd .. | |
- name: Check for changes | |
id: git-check | |
run: | | |
git add . -v | |
if git diff-index --quiet HEAD; then | |
echo "changes=false" >> $GITHUB_OUTPUT | |
else | |
echo "changes=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit and push changes | |
if: steps.git-check.outputs.changes == 'true' | |
run: | | |
git commit -m "Apply formatting and update dependencies" --allow-empty | |
git push -v |