aboutsummaryrefslogtreecommitdiff
path: root/.forgejo/workflows/format.yml
blob: 0f3d54884f8dddf65c0e8630fde7d89760caf19e (plain)
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
name: Format sites
on:
  push:
    branches:
      - master
jobs:
  format-sites:
    runs-on: codeberg-small
    container:
      image: alpine:edge
    steps:
      - name: Install packages
        run: apk add --no-cache yq git openssh
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Skip if last commit is from the bot
        run: |
          if git log -1 --pretty=format:'%an' | grep -q "Formatting Bot"; then
            echo "Last commit by bot, skipping"
            exit 0
          fi
      - 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)