Skip to content

Commit 7bb3cb6

Browse files
authored
fmt action
This workflow formats Rust code and builds the project when manually triggered.
1 parent 7a2d2a3 commit 7bb3cb6

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/fmt.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Manual Auto Format and Build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'Branch to run on'
8+
required: true
9+
default: ${{ github.ref_name }}
10+
11+
jobs:
12+
format-and-build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
ref: ${{ github.event.inputs.branch }}
20+
21+
- name: Install Rust
22+
uses: actions-rs/toolchain@v1
23+
with:
24+
toolchain: stable
25+
components: rustfmt
26+
27+
- name: Run cargo fmt
28+
run: cargo fmt --all
29+
30+
- name: Run cargo build
31+
run: cargo build --verbose
32+
33+
- name: Commit and Push Formatted Changes
34+
if: success()
35+
run: |
36+
if [ -n "$(git status --porcelain)" ]; then
37+
git config user.name 'github-actions[bot]'
38+
git config user.email 'github-actions[bot]@users.noreply.github.com'
39+
git add .
40+
git commit -m "fmt"
41+
git push origin ${{ github.event.inputs.branch }}
42+
fi

0 commit comments

Comments
 (0)