4
4
types : [created]
5
5
6
6
jobs :
7
- deploy :
7
+ fix-linting :
8
8
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords
9
9
if : >
10
10
contains(github.event.comment.html_url, '/pull/') &&
@@ -13,43 +13,77 @@ jobs:
13
13
runs-on : ubuntu-latest
14
14
steps :
15
15
# Use the @nf-core-bot token to check out so we can push later
16
- - uses : actions/checkout@v4
16
+ - uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
17
17
with :
18
18
token : ${{ secrets.nf_core_bot_auth_token }}
19
19
20
+ # indication that the linting is being fixed
21
+ - name : React on comment
22
+ uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
23
+ with :
24
+ comment-id : ${{ github.event.comment.id }}
25
+ reactions : eyes
26
+
20
27
# Action runs on the issue comment, so we don't get the PR by default
21
28
# Use the gh cli to check out the PR
22
29
- name : Checkout Pull Request
23
30
run : gh pr checkout ${{ github.event.issue.number }}
24
31
env :
25
32
GITHUB_TOKEN : ${{ secrets.nf_core_bot_auth_token }}
26
33
27
- - uses : actions/setup-node@v4
34
+ # Install and run pre-commit
35
+ - uses : actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5
36
+ with :
37
+ python-version : 3.11
28
38
29
- - name : Install Prettier
30
- run : npm install -g prettier @prettier/plugin-php
39
+ - name : Install pre-commit
40
+ run : pip install pre-commit
31
41
32
- # Check that we actually need to fix something
33
- - name : Run 'prettier --check'
34
- id : prettier_status
35
- run : |
36
- if prettier --check ${GITHUB_WORKSPACE}; then
37
- echo "result=pass" >> $GITHUB_OUTPUT
38
- else
39
- echo "result=fail" >> $GITHUB_OUTPUT
40
- fi
42
+ - name : Run pre-commit
43
+ id : pre-commit
44
+ run : pre-commit run --all-files
45
+ continue-on-error : true
41
46
42
- - name : Run 'prettier --write'
43
- if : steps.prettier_status.outputs.result == 'fail'
44
- run : prettier --write ${GITHUB_WORKSPACE}
47
+ # indication that the linting has finished
48
+ - name : react if linting finished succesfully
49
+ if : steps.pre-commit.outcome == 'success'
50
+ uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
51
+ with :
52
+ comment-id : ${{ github.event.comment.id }}
53
+ reactions : " +1"
45
54
46
55
- name : Commit & push changes
47
- if : steps.prettier_status.outputs.result == 'fail'
56
+ id : commit-and-push
57
+ if : steps.pre-commit.outcome == 'failure'
48
58
run : |
49
59
git config user.email "[email protected] "
50
60
git config user.name "nf-core-bot"
51
61
git config push.default upstream
52
62
git add .
53
63
git status
54
- git commit -m "[automated] Fix linting with Prettier "
64
+ git commit -m "[automated] Fix code linting "
55
65
git push
66
+
67
+ - name : react if linting errors were fixed
68
+ id : react-if-fixed
69
+ if : steps.commit-and-push.outcome == 'success'
70
+ uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
71
+ with :
72
+ comment-id : ${{ github.event.comment.id }}
73
+ reactions : hooray
74
+
75
+ - name : react if linting errors were not fixed
76
+ if : steps.commit-and-push.outcome == 'failure'
77
+ uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
78
+ with :
79
+ comment-id : ${{ github.event.comment.id }}
80
+ reactions : confused
81
+
82
+ - name : react if linting errors were not fixed
83
+ if : steps.commit-and-push.outcome == 'failure'
84
+ uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
85
+ with :
86
+ issue-number : ${{ github.event.issue.number }}
87
+ body : |
88
+ @${{ github.actor }} I tried to fix the linting errors, but it didn't work. Please fix them manually.
89
+ See [CI log](https://github.com/nf-core/taxprofiler/actions/runs/${{ github.run_id }}) for more details.
0 commit comments