Skip to content
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 workflows from github actions bot #890

Merged
merged 2 commits into from
Dec 24, 2024
Merged

Trigger workflows from github actions bot #890

merged 2 commits into from
Dec 24, 2024

Conversation

osterman
Copy link
Member

@osterman osterman commented Dec 24, 2024

what

  • Call workflow dispatch to build previews and run tests

why

  • Automated PRs from github-actions[bot] will not trigger workflows (by design) unless a PAT is used
  • This approach doesn't require introcing a PAT and leverages mergify instead

tests

Summary by CodeRabbit

  • New Features
    • Introduced automated handling for pull requests, including conditions for bot authors, default branches, and open status.
    • Added a new rule to trigger a workflow dispatch when a pull request is synchronized by the GitHub Actions bot.

@osterman osterman requested a review from a team as a code owner December 24, 2024 15:57
@mergify mergify bot added the triage Needs triage label Dec 24, 2024
Copy link

mergify bot commented Dec 24, 2024

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify bot added the needs-cloudposse Needs Cloud Posse assistance label Dec 24, 2024
goruha
goruha previously approved these changes Dec 24, 2024
@mergify mergify bot removed the triage Needs triage label Dec 24, 2024
Copy link
Contributor

coderabbitai bot commented Dec 24, 2024

Warning

Rate limit exceeded

@osterman has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 82d02b4 and 519b6e0.

📒 Files selected for processing (1)
  • .github/mergify.yml (1 hunks)
📝 Walkthrough

Walkthrough

The pull request introduces a new configuration in .github/mergify.yml to enhance automated pull request handling. By defining shared conditions like is_a_bot, is_default_branch, and is_open, the configuration creates a more flexible and reusable approach to managing GitHub Actions workflows. The new rule enables a workflow dispatch when pull requests are synchronized by the GitHub Actions bot, specifically targeting preview builds and test workflows.

Changes

File Change Summary
.github/mergify.yml - Added shared conditions: is_a_bot, is_default_branch, is_open
- Introduced new pull request rule for workflow dispatch on bot-synchronized PRs

Possibly related PRs

  • Mergify #862: Modifications to .github/mergify.yml configuration for pull request management

Suggested labels

no-release

Suggested reviewers

  • kevcube
  • gberenice
  • aknysh

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a27442 and 82d02b4.

📒 Files selected for processing (1)
  • .github/mergify.yml (1 hunks)
🔇 Additional comments (2)
.github/mergify.yml (2)

22-27: 🛠️ Refactor suggestion

Add synchronization event check

The rule name suggests it should trigger on PR synchronization, but there's no explicit check for this event. This could cause unnecessary workflow runs.

Add the synchronization check:

   conditions:
+    - "check-success~=^Synchronization complete"
     - and: *is_a_bot
     - and: *is_open
     - and: *is_default_branch

Likely invalid or redundant comment.


28-38: Consider adding error handling and rate limiting

The workflow dispatch configuration could benefit from some additional safeguards:

  1. Error handling for failed dispatches
  2. Rate limiting to prevent excessive triggers

Consider adding:

   actions:
     comment:
       message: |
         Triggering the workflow dispatch for preview build...
+        # Add a unique identifier for tracking
+        ID: {{ pull_request.number }}-{{ pull_request.head.sha }}
     github_actions:
       workflow:
         dispatch:
           - workflow: website-preview-build.yml
             ref: "{{ pull_request.head.ref }}"
+            # Add rate limiting
+            max_dispatch_per_hour: 5
           - workflow: test.yml
             ref: "{{ pull_request.head.ref }}"
+            max_dispatch_per_hour: 5

Let's verify the workflow files exist:

.github/mergify.yml Outdated Show resolved Hide resolved
.github/mergify.yml Outdated Show resolved Hide resolved
@osterman osterman merged commit b406027 into main Dec 24, 2024
12 checks passed
@osterman osterman deleted the workflow-dispatch branch December 24, 2024 16:06
@mergify mergify bot removed the needs-cloudposse Needs Cloud Posse assistance label Dec 24, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 24, 2024
Copy link

These changes were released in v1.131.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants