forked from w3f/Grant-Milestone-Delivery
-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (38 loc) · 1.36 KB
/
prettier_format.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
name: Prettier Auto-Format
on:
push:
branches:
- feat/add-prettier-format
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Check Out Repository
uses: actions/checkout@v2
- name: Install Prettier
run: npm install prettier --global
- name: Get Modified Files
id: modified-files
run: |
modified_files=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }})
echo "Modified files: $modified_files" > env_file
- name: Read Modified Files
id: read-env
run: echo "::set-env name=MODIFIED_FILES::$(cat env_file)"
- name: Format Modified Files
if: ${{ steps.read-env.outputs.MODIFIED_FILES != '' }}
run: |
modified_files=${{ steps.read-env.outputs.MODIFIED_FILES }}
prettier --write $modified_files
- name: Commit Changes
if: ${{ steps.read-env.outputs.MODIFIED_FILES != '' }}
run: |
git config --global user.name "Your GitHub Username"
git config --global user.email "[email protected]"
git add .
git commit -m "Auto-format code with Prettier [skip ci]"
- name: Push Changes
if: ${{ steps.read-env.outputs.MODIFIED_FILES != '' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}