forked from MultiQC/MultiQC
-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (48 loc) · 1.62 KB
/
fix_linting.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
50
51
52
53
54
55
56
name: Fix linting
on:
issue_comment:
types: [created]
jobs:
fix_linting:
runs-on: ubuntu-latest
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords
if: >
github.repository_owner == 'MultiQC' &&
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '@multiqc-bot fix linting')
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.MQC_BOT_GITHUB_TOKEN }}
# Action runs on the issue comment, so we don't get the PR by default.
# Use the GitHub CLI to check out the PR:
- name: Checkout Pull Request
env:
GITHUB_TOKEN: ${{ secrets.MQC_BOT_GITHUB_TOKEN }}
run: gh pr checkout ${{ github.event.issue.number }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
pre-commit install
- name: Run pre-commit
run: |
pre-commit run --all-files || true
- name: Check if any files changed
run: |
git diff --exit-code || echo "changed=YES" >> $GITHUB_ENV
echo "Files changed: ${{ env.changed }}"
- name: Commit and push changes
if: env.changed == 'YES'
run: |
git config user.name 'MultiQC Bot'
git config user.email '[email protected]'
git config push.default upstream
git add .
git status
git commit -m "[automated] Fix code linting"
git push