-
Notifications
You must be signed in to change notification settings - Fork 14
66 lines (59 loc) · 1.69 KB
/
dprint-fmt.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
name: Format PR with dprint
on:
pull_request:
types: [labeled]
branches:
- main
workflow_dispatch:
jobs:
pr-fmt:
if: ${{ github.event.label.name == 'S-fmt' && github.repository_owner == 'rustic-rs' }}
name: Format PR
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.base.sha }}
- name: Install dprint
shell: bash
run: |
curl -fsSL https://dprint.dev/install.sh | sh
echo "/home/runner/.dprint/bin" >> $GITHUB_PATH
- name: Format PR
shell: bash
run: ~/.dprint/bin/dprint fmt
- name: Commit changes
shell: bash
run: |
git config --local user.name github-actions
git config --local user.email github-actions@github.com
git add .
git commit -m "Format PR"
git push
remove-fmt-label:
name: Remove fmt label
needs: pr-fmt
permissions:
contents: read
issues: write
pull-requests: write
runs-on: ubuntu-latest
if: |
always() &&
! contains(needs.*.result, 'skipped') &&
github.repository_owner == 'rustic-rs'
steps:
- name: Remove label
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels/S-fmt