Update go-format-check.yml #2
Workflow file for this run
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 Commit Lint Check | |
on: | |
push: | |
branches-ignore: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
gofmt-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
- name: Run gofmt to check formatting | |
run: | | |
unformatted=$(gofmt -l .) | |
if [ -n "$unformatted" ]; then | |
echo "Go code is not properly formatted:" | |
echo "$unformatted" | |
exit 1 | |
else | |
echo "Go code is properly formatted." | |
fi | |
commitlint: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- run: npm install -g @commitlint/cli @commitlint/config-conventional | |
- name: Validate PR commits | |
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose | |
validate-branch-commits: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- run: npm install -g @commitlint/cli @commitlint/config-conventional | |
- name: Validate branch commits | |
run: | | |
git log --format="%s" origin/main..HEAD | xargs -I {} echo '{}' | npx commitlint --verbose |