Skip to content

Adding cloudflare preview builds #822

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

Merged
merged 2 commits into from
May 3, 2025

Conversation

blckmn
Copy link
Member

@blckmn blckmn commented May 3, 2025

This pull request introduces a new GitHub Actions workflow to automate preview deployments for pull requests targeting the master branch. The workflow includes steps for building the project, deploying to Cloudflare, and commenting the preview URL back on the pull request.

New GitHub Actions Workflow for Preview Deployments:

  • .github/workflows/deploy-preview.yml: Added a new workflow named Preview Deployment that triggers on pull requests targeting the master branch. The workflow includes steps for caching dependencies, installing Node.js, building the project with Yarn, deploying to Cloudflare using the Wrangler action, and commenting the preview URL on the pull request.

Summary by CodeRabbit

  • New Features
    • Introduced automated preview deployments for pull requests targeting the master branch. Deployment URLs are posted directly on the pull request for easy access and review.

Copy link

coderabbitai bot commented May 3, 2025

"""

Walkthrough

A new GitHub Actions workflow file named deploy-preview.yml has been added under the .github/workflows directory. This workflow is designed to trigger on pull requests targeting the master branch. It performs a sequence of steps including checking out the code, caching dependencies, setting up Node.js and Yarn, installing dependencies, building the project, deploying the build output to Cloudflare Pages, and commenting the deployment URL on the pull request with appropriate reactions and tagging.

Changes

File(s) Change Summary
.github/workflows/deploy-preview.yml Added a new workflow for preview deployment on pull requests to master, automating build, deploy to Cloudflare Pages, and PR commenting.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub PR as GitHub PR (to master)
    participant Actions as GitHub Actions Runner
    participant Cloudflare as Cloudflare Pages
    participant PR as Pull Request

    GitHub PR->>Actions: Trigger workflow on PR to master
    Actions->>Actions: Checkout code, cache dependencies
    Actions->>Actions: Setup Node.js & Yarn, install dependencies
    Actions->>Actions: Build project (yarn build)
    Actions->>Cloudflare: Deploy build output (src/dist)
    Cloudflare-->>Actions: Return deployment URL
    Actions->>PR: Comment with deployment URL and add reactions
Loading

Poem

🐰
A workflow hops in, shiny and new,
Building and caching, as bunnies do.
With Cloudflare magic, a preview appears,
And comments with rockets bring digital cheers.
Now every pull request can plainly see—
A preview deployed, as quick as can be!
🚀👀
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60b2c62 and a416a99.

📒 Files selected for processing (1)
  • .github/workflows/deploy-preview.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/deploy-preview.yml

🪧 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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 to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@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: 2

🧹 Nitpick comments (1)
.github/workflows/deploy-preview.yml (1)

20-25: Leverage setup-node built-in caching
Instead of manually caching node_modules, you can combine Node.js setup and Yarn cache:

- name: Install node.js (with cache)
  uses: actions/setup-node@v4
  with:
    node-version-file: '.nvmrc'
    cache: 'yarn'
    cache-dependency-path: yarn.lock

This simplifies the workflow and speeds up dependency installs.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3639e69 and 60b2c62.

📒 Files selected for processing (1)
  • .github/workflows/deploy-preview.yml (1 hunks)
🔇 Additional comments (6)
.github/workflows/deploy-preview.yml (6)

1-1: Workflow name is clear
The name: 'Preview Deployment' succinctly describes this workflow.


2-5: Verify use of pull_request_target
Using pull_request_target grants access to secrets but runs the workflow against the base branch code. Ensure this is intentional and that no untrusted PR code can modify the workflow or exfiltrate secrets.


14-15: No action required for runner and timeout
The runs-on: ubuntu-latest and timeout-minutes: 5 settings are reasonable defaults; adjust only if your build routinely exceeds 5 minutes.


26-33: No action required for Node.js and Yarn installation
The steps to install Node.js via .nvmrc and then globally install Yarn are standard. Pinning Yarn to a specific version or using built-in cache flags is optional.


35-42: Verify build output path
Confirm that your build actually emits files to src/dist. If the output directory differs (e.g., a top-level dist/), update the deploy command accordingly:

- pages deploy src/dist --project-name=...
+ pages deploy dist --project-name=...

43-51: No action required for comment step
Using actions-comment-pull-request with reactions and mode: recreate is a solid approach for surfacing the preview URL.

Comment on lines +17 to +19
- name: Checkout code
uses: actions/checkout@v4

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Checkout PR head commit on pull_request_target
By default, actions/checkout in a pull_request_target event checks out the base branch. To build the PR changes, specify the head ref:

-      - uses: actions/checkout@v4
+      - uses: actions/checkout@v4
+        with:
+          ref: ${{ github.event.pull_request.head.sha }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

Comment on lines +9 to +13
permissions:
actions: read
contents: read
deployments: write
pull-requests: write
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add issues: write permission for PR comments
To allow the comment action to post deployment URLs on the pull request, include the issues: write permission under permissions.

 permissions:
   actions: read
   contents: read
   deployments: write
+  issues: write
   pull-requests: write
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions:
actions: read
contents: read
deployments: write
pull-requests: write
permissions:
actions: read
contents: read
deployments: write
issues: write
pull-requests: write

haslinghuis
haslinghuis previously approved these changes May 3, 2025
with:
message: |
Preview URL: ${{ steps.deploy.outputs.deployment-url }}
reactions: eyes, rocket
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
reactions: eyes, rocket

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this updates the single comment (recreation mode) issue.

I'm keeping the emojis though :)

Copy link

sonarqubecloud bot commented May 3, 2025

@haslinghuis haslinghuis merged commit d67e9f9 into betaflight:master May 3, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants