mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-21 10:48:18 +00:00
Teach nf-core bot to fix lint (#2109)
* Teach nf-core bot to lint * Correct file * Add empty line at end of file * Ran prettier Co-authored-by: SPearce <simon.pearce@cruk.manchester.ac.uk> Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>
This commit is contained in:
parent
eb15df8036
commit
5da2c37458
1 changed files with 54 additions and 0 deletions
54
.github/workflows/fix-linting.yml
vendored
Normal file
54
.github/workflows/fix-linting.yml
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
name: Fix linting from a comment
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords
|
||||
if: >
|
||||
contains(github.event.comment.html_url, '/pull/') &&
|
||||
contains(github.event.comment.body, '@nf-core-bot fix linting') &&
|
||||
github.repository == '{{ name }}' {%- raw %}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Use the @nf-core-bot token to check out so we can push later
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.nf_core_bot_auth_token }}
|
||||
|
||||
# Action runs on the issue comment, so we don't get the PR by default
|
||||
# Use the gh cli to check out the PR
|
||||
- name: Checkout Pull Request
|
||||
run: gh pr checkout ${{ github.event.issue.number }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.nf_core_bot_auth_token }}
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
|
||||
- name: Install Prettier
|
||||
run: npm install -g prettier @prettier/plugin-php
|
||||
|
||||
# Check that we actually need to fix something
|
||||
- name: Run 'prettier --check'
|
||||
id: prettier_status
|
||||
run: |
|
||||
if prettier --check ${GITHUB_WORKSPACE}; then
|
||||
echo "::set-output name=result::pass"
|
||||
else
|
||||
echo "::set-output name=result::fail"
|
||||
fi
|
||||
- name: Run 'prettier --write'
|
||||
if: steps.prettier_status.outputs.result == 'fail'
|
||||
run: prettier --write ${GITHUB_WORKSPACE}
|
||||
|
||||
- name: Commit & push changes
|
||||
if: steps.prettier_status.outputs.result == 'fail'
|
||||
run: |
|
||||
git config user.email "core@nf-co.re"
|
||||
git config user.name "nf-core-bot"
|
||||
git config push.default upstream
|
||||
git add .
|
||||
git status
|
||||
git commit -m "[automated] Fix linting with Prettier"
|
||||
git push {%- endraw %}
|
Loading…
Reference in a new issue