-
Notifications
You must be signed in to change notification settings - Fork 244
51 lines (46 loc) · 1.85 KB
/
format-command.yml
File metadata and controls
51 lines (46 loc) · 1.85 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
51
name: format-command
on:
repository_dispatch:
types: [format-command]
jobs:
format:
runs-on: ubuntu-latest
steps:
# Generate token from GenericMappingTools bot
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
# Checkout the pull request branch
- uses: actions/checkout@v2
with:
token: ${{ steps.generate-token.outputs.token }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
# Setup Python environment
- uses: actions/setup-python@v1
# Install formatting tools
- name: Install formatting tools
run: |
pip install black blackdoc flake8
sudo apt-get install dos2unix
# Run "make format" and commit the change to the PR branch
- name: Commit to the PR branch if any changes
run: |
make format
find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix {} \;
find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec chmod 644 {} \;
if [[ $(git ls-files -m) ]]; then
git config --global user.name 'actions-bot'
git config --global user.email '58130806+actions-bot@users.noreply.github.com'
git commit -am "[format-command] fixes"
git push
fi
- name: Add reaction
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ steps.generate-token.outputs.token }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reaction-type: hooray