-
Notifications
You must be signed in to change notification settings - Fork 569
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
Improve trigger condition in github actions #828
Conversation
PR Description updated to latest commit (493f73f)
|
PR Review
✨ Review tool usage guide:Overview: The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
See the review usage page for a comprehensive guide on using this tool. |
PR Code Suggestions
✨ Improve tool usage guide:Overview:
See the improve usage page for a comprehensive guide on using this tool. |
docs/docs/installation/github.md
Outdated
```yaml | ||
on: | ||
pull_request: | ||
types: [opened,reopened,ready_for_review,review_requested] | ||
issue_comment: | ||
jobs: | ||
pr_agent_job: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ask can i limit the 'issue_comment' to ignore bots ? can I limit it to ignore message not starting with '/' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you can limit the issue_comment
trigger to ignore bots and to only act on comments that start with a /
. However, these configurations are not directly available through the on.issue_comment
syntax in the GitHub Actions YAML file. Instead, you would need to implement conditional checks within the jobs of your GitHub Action workflow. Here's how you can approach it:
-
Ignore Bots: GitHub Actions provides a
github
context which contains information about the event that triggered the workflow. You can use thegithub.actor
attribute to check if the actor is a bot. Bots typically have[bot]
at the end of their username. -
Filter Comments Starting with '/': You can use the
github.event.comment.body
attribute to access the content of the comment and then check if it starts with a/
.
Here is an example of how you might implement these checks in a job within your GitHub Actions workflow:
jobs:
pr_agent_job:
if: >-
!contains(github.actor, '[bot]') &&
startsWith(github.event.comment.body, '/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
# Add other steps as needed
In this example:
- The
if
condition for the jobpr_agent_job
checks two things:- It uses
!contains(github.actor, '[bot]')
to ensure the actor is not a bot. - It uses
startsWith(github.event.comment.body, '/')
to ensure the comment starts with a/
.
- It uses
- If both conditions are true, the job proceeds; otherwise, it's skipped.
This approach allows you to dynamically control the execution of your GitHub Actions based on the content and source of issue comments.
@idubnori Also, another optimization I want is to ignore bots. So the action should be:
there are additional optimizations that can be done (ignore comments if they don't start with '/', for example), but lets leave them to future PRs. Adpat the PR to the condition above, and we can merge it |
@mrT23 Thank you for your reviewing. fixed them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
User description
fix: #827
Type
enhancement, documentation
Description
types
forpull_request
events. This specifies the action to run onopened
,reopened
,ready_for_review
, andreview_requested
events, improving the trigger condition.Changes walkthrough
github_action_runner.py
Add Logging for Skipped Actions
pr_agent/servers/github_action_runner.py
github.md
Specify GitHub Action Trigger Conditions
docs/docs/installation/github.md
types
topull_request
event to specify when the GitHub Actionshould run.
opened
,reopened
,ready_for_review
, andreview_requested
events.