-
Notifications
You must be signed in to change notification settings - Fork 243
54 lines (47 loc) · 1.69 KB
/
format-command.yml
File metadata and controls
54 lines (47 loc) · 1.69 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
# 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:
permissions:
contents: write # for Git to git push
runs-on: ubuntu-latest
steps:
# Generate token from GenericMappingTools bot
- uses: actions/create-github-app-token@v2.2.1
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
# Checkout the pull request branch
- uses: actions/checkout@v6.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
# Setup Python environment
- name: Set up Python and install dependencies
uses: actions/setup-python@v6.2.0
with:
python-version: '3.14'
pip-install: ruff prek
- name: List installed packages
run: 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