@@ -41,19 +41,43 @@ jobs:
41
41
name : Check formatting
42
42
runs-on : ubuntu-latest
43
43
steps :
44
- - name : Checkout repository
44
+ - name : Checkout repository with token
45
+ if : ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
45
46
uses : actions/checkout@v3
46
-
47
+ with :
48
+ fetch-depth : 0
49
+ ref : ${{ github.event.pull_request.head.ref }}
50
+ token : ${{ secrets.AUTO_FILE_UPDATE_PAT }}
51
+
52
+ - name : Checkout repository for fork
53
+ if : ${{ github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
54
+ uses : actions/checkout@v3
55
+
47
56
- name : Install Rust
48
57
uses : dtolnay/rust-toolchain@master
49
58
with :
50
59
toolchain : nightly
51
60
components : rustfmt
52
61
53
- - name : Check formatting
62
+ - name : Check formatting for forked pull requests
63
+ if : ${{ github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
54
64
shell : bash
55
65
run : cargo +nightly fmt --all --check
56
66
67
+ - name : Run formatter
68
+ if : ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
69
+ shell : bash
70
+ run : |
71
+ cargo +nightly fmt --all
72
+ if ! git diff --exit-code --quiet -- crates; then
73
+ echo "::notice::Formatting check failed"
74
+ git config --local user.name 'github-actions[bot]'
75
+ git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
76
+ git add crates
77
+ git commit --message 'chore: run formatter'
78
+ git push
79
+ fi
80
+
57
81
check-msrv :
58
82
name : Check compilation on MSRV toolchain
59
83
runs-on : ${{ matrix.os }}
@@ -275,8 +299,17 @@ jobs:
275
299
# - windows-latest
276
300
277
301
steps :
278
- - name : Checkout repository
302
+ - name : Checkout repository for fork
303
+ if : ${{ (github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) }}
304
+ uses : actions/checkout@v3
305
+
306
+ - name : Checkout repository with token
307
+ if : ${{ (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) }}
279
308
uses : actions/checkout@v3
309
+ with :
310
+ fetch-depth : 0
311
+ ref : ${{ github.event.pull_request.head.ref }}
312
+ token : ${{ secrets.AUTO_FILE_UPDATE_PAT }}
280
313
281
314
- name : " Fetch base branch"
282
315
shell : bash
@@ -322,6 +355,18 @@ jobs:
322
355
shell : bash
323
356
run : cargo clippy --all-features --all-targets
324
357
358
+ - name : Check Cargo.lock changed
359
+ if : ${{ (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) }}
360
+ shell : bash
361
+ run : |
362
+ if ! git diff --quiet --exit-code -- Cargo.lock ; then
363
+ git config --local user.name 'github-actions[bot]'
364
+ git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
365
+ git add Cargo.lock
366
+ git commit --message 'chore: update Cargo.lock'
367
+ git push
368
+ fi
369
+
325
370
- name : Check files changed
326
371
shell : bash
327
372
run : |
0 commit comments