aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/go.fmt.yml
blob: 9fe10504ae758e721e3dcc5e8823a74d58245a28 (plain) (blame)
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
name: Go Fmt

on:
  schedule:
    - cron: '22 10 * * 1'

permissions: read-all

jobs:
  fix:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout
        uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846

      - name: Fmt
        run: |
          find . -not -path '*/\.git/*' -type f -name '*.go' -exec gofmt -s -w {} \+

      - name: Set up Git
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          git config user.name "coredns[bot]"
          git config user.email "bot@bot.coredns.io"
          git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git

      - name: Commit and push changes
        run: |
          git add .
          if output=$(git status --porcelain) && [ ! -z "$output" ]; then
            git commit -s -m 'auto go fmt'
            git push
          fi