Repository navigation
56 lines (49 loc) · 1.85 KB
/
Copy pathformat-command.yml
File metadata and controls
56 lines (49 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
52
53
54
55
56
# Format the codes using slash command
#
# This workflow is triggered in a PR if the slash command `/format` is used.
#
name: format-command
on:
repository_dispatch:
types: [format-command]
permissions: {}
jobs:
format:
environment: pr-tests
permissions:
contents: write # for Git to git push
runs-on: ubuntu-slim
steps:
# Generate token from GenericMappingTools bot
- uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
id: generate-token
with:
client-id: ${{ vars.CLIENT_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-contents: write
# Checkout the pull request branch
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
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 }}
persist-credentials: true
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.15'
- name: Install formatting tools
run: |
python -m pip install --group style
python -m pip list
# Run "make format" and commit the change to the PR branch
- name: Commit to the PR branch if any changes
run: |
# Use '|| true' to ensure the workflow doesn't stop when `make format` fails
make format || true
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