-
Notifications
You must be signed in to change notification settings - Fork 50
34 lines (29 loc) · 1.12 KB
/
config-validated.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
name: Validate GitHub Org Configuration
on:
pull_request:
paths:
- "config.yaml"
# Declare default permissions as read only.
permissions: read-all
jobs:
config-validated:
runs-on: ubuntu-latest
name: config-validated
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Lowercase and sort config.yaml key and values
uses: mikefarah/yq@8bf425b4d1344db7cd469a8d10a390876e0c77fd # v4.45.1
with:
cmd: yq -i e '(... | select(type == "!!seq"))[] |= downcase' config.yaml && yq -i e '(... | select(type == "!!seq")) |= sort' config.yaml && yq -i 'sort_keys(..)' config.yaml
- name: Check if there are changes to config.yaml
id: changes
run: echo "changed=$(git status --porcelain config.yaml | wc -l)" >> $GITHUB_OUTPUT
- name: Fail if config.yaml changes found
if: steps.changes.outputs.changed >= 1
run: |
echo "Uncommitted changes to config.yaml exist. Failing."
echo
git status --porcelain
git --no-pager diff config.yaml
exit 1