-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger Lint Action on PR comment ? #559
Comments
Only Could you explain why you need to run the action on |
@ocean90 thanks for the reply. I wanted this action to run on issue_comment so that the lint does not run on each push of the pull request and can just be run when a dev wants to lint his PR (for ex: before putting it up for review). Here is the way I am currently using it name: Lint (auto fix)
on:
issue_comment:
types: [created]
jobs:
check-comment:
if: github.event.issue.pull_request
name: Check Comment
runs-on: ubuntu-latest
outputs:
status: ${{ steps.check.outputs.triggered }}
pr: ${{ steps.get-pr.outputs.result }}
steps:
- uses: Khan/[email protected]
id: check
with:
trigger: '@run-lint'
reaction: eyes
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- uses: actions/[email protected]
id: get-pr
with:
retries: 2
script: |
return github.rest.pulls.get({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
run-linters:
needs: check-comment
name: Run linters
runs-on: ubuntu-latest
if: needs.check-comment.outputs.status == 'true'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ fromJson(needs.check-comment.outputs.pr).data.head.ref }}
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 14.17.6
- name: Install Node.js dependencies
run: npm ci
- name: Run linters
run: npm run format && (npm run lint:fix || true) # Ideally I would want to use lint-action for the individual status checks for prettier / eslint
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Lint Fixes
branch: ${{ fromJson(needs.check-comment.outputs.pr).data.head.ref }}
The reason for not using lint with |
I see. Please feel free to submit a PR that adds support for the |
Sure, I will take this up in this or the next week. I am assuming the only change that needs to happed is to add support for lint-action/src/github/context.js Lines 68 to 82 in 640cbd3
return github.rest.pulls.get({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
}) |
Hi @ocean90 can I use the @actions/github package or is the Rest API call (to fetch the repo branch from PR) to be made manually. The package does provide a Github client and context which should make the task easier and maybe even the current context fetching function and related logic can be done using this ? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi @ocean90 any update on this ? |
I was trying to trigger this action when a specific comment is made on the PR. However I got the following error
Error: lint-action does not support "issue_comment" GitHub events
So, I would like to know which github events are supported by this action and how could I go about solving my use case ?
The text was updated successfully, but these errors were encountered: