yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie HermaszewskaCorrect URL in auto-format PR body (#5427)d38fbaefe

master
3.9 KiB85 linesraw
1name: Format
2on:
3  repository_dispatch:
4    types: [format-command]
5jobs:
6  format:
7    runs-on: ubuntu-latest
8    steps:
9      - name: Checkout PR branch
10        uses: actions/checkout@v4
11        with:
12          token: ${{ secrets.SLANGBOT_PAT }}
13          repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
14          ref: ${{ github.event.client_payload.pull_request.head.ref }}
15          path: pr-branch
16
17      - name: Checkout target branch
18        uses: actions/checkout@v4
19        with:
20          token: ${{ secrets.SLANGBOT_PAT }}
21          repository: ${{ github.event.client_payload.pull_request.base.repo.full_name }}
22          ref: ${{ github.event.client_payload.pull_request.base.ref }}
23          path: target-branch
24
25      - name: Setup
26        uses: ./target-branch/.github/actions/format-setup
27
28      - name: Run formatting
29        id: format
30        run: |
31          ./target-branch/extras/formatting.sh --source ./pr-branch
32
33      - name: Configure Git commit signing
34        id: git-info
35        run: |
36          echo "${{ secrets.SLANGBOT_SIGNING_KEY }}" > "${{runner.temp}}"/signing_key
37          chmod 600 "${{runner.temp}}"/signing_key
38          git -C pr-branch config commit.gpgsign true
39          git -C pr-branch config gpg.format ssh
40          git -C pr-branch config user.signingkey "${{runner.temp}}"/signing_key
41          bot_info=$(curl -s -H "Authorization: Bearer ${{ secrets.SLANGBOT_PAT }}" \
42            "https://api.github.com/user")
43          echo "bot_identity=$(echo $bot_info | jq --raw-output '.login + " <" + (.id|tostring) + "+" + .login + "@users.noreply.github.com>"')" >> $GITHUB_OUTPUT
44          echo "bot_name=$(echo $bot_info | jq --raw-output '.login')" >> $GITHUB_OUTPUT
45
46      - name: Create Pull Request
47        id: create-pr
48        uses: peter-evans/create-pull-request@v7
49        with:
50          token: ${{ secrets.SLANGBOT_PAT }}
51          path: pr-branch
52          commit-message: "format code"
53          title: "Format code for PR #${{ github.event.client_payload.pull_request.number }}"
54          body: "Automated code formatting for ${{ github.event.client_payload.pull_request.html_url }}"
55          committer: ${{ steps.git-info.outputs.bot_identity }}
56          author: ${{ steps.git-info.outputs.bot_identity }}
57          branch: format-${{ github.event.client_payload.pull_request.number }}-${{ github.event.client_payload.pull_request.head.ref }}
58          base: ${{ github.event.client_payload.pull_request.head.ref }}
59          push-to-fork: ${{ steps.git-info.outputs.bot_name }}/slang
60          delete-branch: true
61
62      - name: Comment on PR
63        uses: peter-evans/create-or-update-comment@v4
64        if: always()
65        with:
66          token: ${{ secrets.SLANGBOT_PAT }}
67          repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
68          issue-number: ${{ github.event.client_payload.pull_request.number }}
69          body: |
70            ${{ 
71              steps.format.conclusion == 'failure'
72              && format('❌ Formatting failed. Please check the [workflow run](https://github.com/{0}/actions/runs/{1})', github.repository, github.run_id)
73              || (steps.create-pr.conclusion == 'failure' 
74                  && format('❌ Failed to create formatting pull request. Please check the [workflow run](https://github.com/{0}/actions/runs/{1})', github.repository, github.run_id)
75                  || format('🌈 Formatted, please merge the changes from [this PR]({0})', steps.create-pr.outputs.pull-request-url))
76            }}
77
78      - name: Add reaction
79        uses: peter-evans/create-or-update-comment@v4
80        with:
81          token: ${{ secrets.SLANGBOT_PAT }}
82          repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
83          comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
84          reactions-edit-mode: replace
85          reactions: hooray