-
Notifications
You must be signed in to change notification settings - Fork 89
50 lines (44 loc) · 1.21 KB
/
format.yml
File metadata and controls
50 lines (44 loc) · 1.21 KB
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
name: Format
# Runs `cargo fmt` (Rust formatter) and `prettier` (JS formatter) whenever code is pushed or pr'd into master.
on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- closed
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- run: rustup component add rustfmt
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all
- name: Run prettier
uses: actionsx/prettier@v2
with:
args: --write .
- name: Commit files # only runs if something actually changed
run: |
if [[ -n "$(git status -s)" ]]; then
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m "CI: Automatic Format" -a
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}