-
Notifications
You must be signed in to change notification settings - Fork 55
41 lines (41 loc) · 1.38 KB
/
yamlformatter.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: Format yaml files
on:
pull_request:
branches: [main]
paths: ['**/*.yml', '**/*.yaml']
permissions:
contents: write
pull-requests: write
jobs:
format-yaml-files:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get file changes
id: get_file_changes
uses: trilom/[email protected]
with:
output: ' '
- name: Select only the yaml files
id: changed_yaml_files
run: |
echo ${{ steps.get_file_changes.outputs.files }} | xargs -n 1 | grep -E "\.yml$|\.yaml$" > changed_files.txt
# Remove dependabot.yml and sync.yml if they exist in the list
sed -i '/.github\/dependabot.yml/d' changed_files.txt || true
sed -i '/.sync.yml/d' changed_files.txt || true
yaml_files=$(cat changed_files.txt | tr '\n' ' ')
rm changed_files.txt
echo "files=${yaml_files}" >> $GITHUB_OUTPUT
- name: Yamlfix
id: yamlfix
uses: comfucios/[email protected]
with:
files: ${{ steps.changed_yaml_files.outputs.files }}
- name: commit-changes
if: ${{ steps.yamlfix.outputs.changed_files == 'true' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply Yamlfix format changes.
status_options: --untracked-files=no