Skip to content

Commit

Permalink
format command
Browse files Browse the repository at this point in the history
  • Loading branch information
expipiplus1 committed Oct 25, 2024
1 parent 5a842d3 commit 9ef4ea3
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
32 changes: 32 additions & 0 deletions .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Slash Command Dispatch
on:
issue_comment:
types: [created]
jobs:
slashCommandDispatch:
runs-on: ubuntu-latest
steps:

- name: Slash Command Dispatch
id: scd
uses: peter-evans/slash-command-dispatch@v4
with:
token: ${{ secrets.SLANGBOT_PAT }}
reaction-token: ${{ secrets.SLANGBOT_PAT }}
config: >
[
{
"command": "format",
"permission": "none",
"issue_type": "pull-request"
}
]
- name: Edit comment with error message
if: steps.scd.outputs.error-message
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.SLANGBOT_PAT }}
comment-id: ${{ github.event.comment.id }}
body: |
> ${{ steps.scd.outputs.error-message }}

0 comments on commit 9ef4ea3

Please sign in to comment.