Skip to content

Code Linting (automated) #105

Code Linting (automated)

Code Linting (automated) #105

Workflow file for this run

name: Code Linting
run-name: Code Linting (automated)
on:
issue_comment:
types: [created]
jobs:
fix-linting:
# 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-scil-bot fix linting') &&
github.repository == 'scilus/nf-scil'
runs-on: scilus-nf-scil-runners
steps:
# Use the @nf-scil-bot token to check out so we can push later
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
# indication that the linting is being fixed
- name: React on comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
reactions: eyes
# 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.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
- 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: Post nothing-to-do comment
if: steps.prettier_status.outputs.result == 'pass'
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.issue.number }}
body: |
Nothing for me to do here! :shrug:
This is probably because the linting errors come from `nf-core lint` and have to be fixed manually (or with `nf-core lint --fix`).
- name: Commit & push changes
if: steps.prettier_status.outputs.result == 'fail'
run: |
git config user.email "scil@nf-sc.il"
git config user.name "nf-scil-bot"
git config push.default upstream
git add .
git status
git commit -m "[automated] Fix linting with Prettier"
git push