-
Notifications
You must be signed in to change notification settings - Fork 1.7k
41 lines (38 loc) · 1.2 KB
/
gofmt.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: gofmt
permissions:
contents: read
on:
pull_request:
paths:
- "**/*.go"
jobs:
run-gofmt:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
- name: Merge base branch
id: pull_request
run: |
git config user.name "modular-magician"
git config user.email "[email protected]"
git fetch origin ${{ github.base_ref }} # Fetch the base branch
git merge --no-ff origin/${{ github.base_ref }} # Merge with the base branch
- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
cache: false
go-version: '^1.23'
- name: gofmt
run: |
GOFMT_OUTPUT="$(gofmt -l .)"
# Currently no simple way to get a non-0 exit code directly from
# gofmt
if [ -n "$GOFMT_OUTPUT" ]; then
echo "The following files are not formatted properly:" >&2
echo "$GOFMT_OUTPUT" >&2
exit 1
fi
echo "gofmt-output=gofmt success" >> "$GITHUB_OUTPUT"