-
Notifications
You must be signed in to change notification settings - Fork 20
42 lines (40 loc) · 1.29 KB
/
yaml_format.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
42
name: Format YAML
on:
push:
branches: # Only run on push events to branches (exclude main)
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
- '!main' # excludes main
merge_group:
jobs:
format:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21.x'
- name: Install dependencies
run: |
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
- name: Format YAML files
run: yamlfmt config
- uses: dorny/[email protected]
id: filter
with:
filters: |
yaml_file_change:
- added|modified: '**.yml'
- name: Add formatting changes
if: steps.filter.outputs.yaml_file_change == 'true'
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git add .
git commit -m "Automatic YAML formatting"
- name: Push changes to current branch
if: steps.filter.outputs.yaml_file_change == 'true'
run: git push origin ${{ github.head_ref }}