-
Notifications
You must be signed in to change notification settings - Fork 26
49 lines (46 loc) · 1.57 KB
/
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
on:
push:
branches-ignore:
- master
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Configure git user
run: |
if [[ -n "${{ secrets.PANTHER_BOT_AUTOMATION_TOKEN }}" ]]; then
echo "GIT_USER_NAME=panther-bot-automation" >> $GITHUB_ENV
echo "GIT_USER_EMAIL=github-service-account-automation@panther.io" >> $GITHUB_ENV
echo "GIT_TOKEN=${{ secrets.PANTHER_BOT_AUTOMATION_TOKEN }}" >> $GITHUB_ENV
else
echo "GIT_USER_NAME=${{ github.actor }}" >> $GITHUB_ENV
echo "GIT_USER_EMAIL=$(git log -n 1 --pretty=format:%ae)" >> $GITHUB_ENV
echo "GIT_TOKEN=${{ github.token }}" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ env.GIT_TOKEN }}
- name: Setup Python
uses: actions/setup-python@v4.3.0
with:
python-version: 3.9.15
- name: Install pipenv
run: make install-pipenv
- name: Install
run: make install
- name: Format
run: make fmt
- name: Commit formatting
run: |
git config --global user.name "$GIT_USER_NAME"
git config --global user.email "$GIT_USER_EMAIL"
git add -A .
REQUIRES_COMMIT=1
git commit -m "Auto-format files" || REQUIRES_COMMIT=0
if [[ $REQUIRES_COMMIT -eq 0 ]]; then
echo "No auto-formatting needed"
else
echo "Committing auto-formatted files"
git push origin HEAD:${{ github.ref }}
fi