aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/format.yml
blob: 9bbe54e77c5783780c057639e9b00b5f56d72c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
name: Format sites
on:
  push:
    branches:
      - master
permissions:
  contents: write
jobs:
  format-sites:
    if: github.actor != 'github-actions[bot]' && !contains(github.event.head_commit.author.name, 'Formatting Bot')
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Format and push
        run: |
          git config user.email "bot@1mb.club"
          git config user.name "Formatting Bot"
          yq --inplace 'sort_by(.domain)' _data/sites.yml
          sed -i '1!s/- domain:/\n- domain:/g' _data/sites.yml
          git diff --quiet || (git commit -am "Fix formatting" && git push)