Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YAML Linter GHA #2786

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/yaml_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Format YAML

on:
pull_request:
push:
branches:
- '!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
- name: Check for changes after formatting
run: |
git diff --exit-code # Check for changes after formatting
id: check_changes
- name: Add formatting changes, push
if: steps.check_changes.outputs == 1
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"
git push origin ${{ github.head_ref }}
Loading