forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (75 loc) · 3.45 KB
/
format.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Format
on:
repository_dispatch:
types: [format-command]
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
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 }}
path: pr-branch
- name: Checkout target branch
uses: actions/checkout@v4
with:
token: ${{ secrets.SLANGBOT_PAT }}
repository: ${{ github.event.client_payload.pull_request.base.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.base.ref }}
path: target-branch
- name: Setup
uses: ./target-branch/.github/actions/format-setup
- name: Run formatting
id: format
run: |
./target-branch/extras/formatting.sh --source ./pr-branch
- name: Comment on errors
if: steps.format.conclusion == 'failure'
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.SLANGBOT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
issue-number: ${{ github.event.client_payload.pull_request.number }}
body: |
❌ Formatting failed. Please check the [workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
- 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
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.SLANGBOT_PAT }}
path: pr-branch
commit-message: "format code"
committer: slangbot 186143334+slangbot@users.noreply.github.com
author: slangbot 186143334+slangbot@users.noreply.github.com
title: "Format code for PR #${{ github.event.client_payload.pull_request.number }}"
body: "Automated code formatting"
branch: format-${{ github.event.client_payload.pull_request.head.ref }}
base: ${{ github.event.client_payload.pull_request.head.ref }}
push-to-fork: slangbot/slang
delete-branch: true
- name: Comment on PR creation failure
if: steps.create-pr.conclusion == 'failure'
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.SLANGBOT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
issue-number: ${{ github.event.client_payload.pull_request.number }}
body: |
❌ Failed to create formatting pull request. Please check the [workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
- 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 }}
edit-mode: replace
reactions: hooray