Skip to content

Commit 0b8c15e

Browse files
committed
Add automatic code reformat
1 parent 4246934 commit 0b8c15e

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

.github/workflows/format.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Reformat code
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}
9+
cancel-in-progress: false
10+
11+
jobs:
12+
format:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Install dependencies
19+
run: |
20+
sudo apt update
21+
22+
sudo apt install python3 black -y
23+
24+
sudo apt install nodejs npm -y
25+
sudo npm i -g prettier
26+
27+
- name: Format python using black
28+
run: black .
29+
- name: Format everything else using prettier
30+
run: prettier . -w
31+
32+
- name: Commit and push changes if any
33+
run: |
34+
if [[ `git status --porcelain` ]]; then
35+
git add .
36+
git commit --author "GitHub Actions <videocreator@outlook.de>" -m "$(echo -e "Reformat code\n\n\nCo-authored-by: $(git log "${{ github.sha }}^..${{ github.sha }}" --pretty=format:'%an <%ae>')")"
37+
git push
38+
else
39+
git status
40+
fi

.github/workflows/test-sha.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)