summaryrefslogtreecommitdiff
path: root/.github/workflows/format.yml
blob: 4a68882ae4bfe4b81b7466dc7881c19f2a71cc42 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Format
on:
  repository_dispatch:
    types: [format-command]
jobs:
  format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ secrets.SLANGBOT_PAT }}
          repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
          ref: ${{ github.event.client_payload.pull_request.head.ref }}

      - run: pip3 install gersemi

      - name: install clang-format
        run: |
          tmpdir=$(mktemp -d)
          curl -L -H "Authorization: token ${{ secrets.SLANGBOT_PAT }}" \
            -o "$tmpdir/clang-format" \
            https://github.com/shader-slang/slang-binaries/raw/4e88845ec51641b4c92e68027e359090bdb219e0/clang-format/x86_64-linux/bin/clang-format
          chmod +x "$tmpdir/clang-format"
          echo "$tmpdir" >> $GITHUB_PATH

      - run: ./extras/formatting.sh

      - name: Configure Git commit signing
        run: |
          echo "${{ secrets.SLANGBOT_SIGNING_KEY }}" > "${{runner.temp}}"/signing_key
          chmod 600 "${{runner.temp}}"/signing_key
          git config commit.gpgsign true
          git config gpg.format ssh
          git config user.signingkey "${{runner.temp}}"/signing_key

      - uses: EndBug/add-and-commit@v9
        with:
          fetch: false
          message: "format code"
          push: true

      - name: Add reaction
        uses: peter-evans/create-or-update-comment@v4
        with:
          token: ${{ secrets.SLANGBOT_PAT }}
          repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
          comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
          reactions-edit-mode: replace
          reactions: hooray