Skip to content

Refactor preview deployments workflows#836

Merged
goruha merged 2 commits intomainfrom
decouple-preview-deployment
Dec 9, 2024
Merged

Refactor preview deployments workflows#836
goruha merged 2 commits intomainfrom
decouple-preview-deployment

Conversation

@goruha
Copy link
Member

@goruha goruha commented Dec 9, 2024

what

  • Decouple website-deploy-preview deployment workflow to website-preview-build and website-preview-deploy workflows
  • Renamed website-destroy-preview workflow to website-preview-destroy
  • Inactivate GitHub deployment on preview destroy workflow

why

  • Support preview environment deployments for PRs from forks
  • Follow workflow naming consistency
  • Support cleaning up environments on preview destroy

references

Summary by CodeRabbit

  • New Features

    • Introduced a new workflow for building website previews.
    • Added steps for deployment initiation and status updates in the deployment workflow.
    • Enhanced the destruction process of website previews with improved permissions and conditional checks.
  • Bug Fixes

    • Adjusted environment variable references for better functionality.
  • Documentation

    • Updated workflow names for clarity and consistency.
    • Changed workflow triggers to enhance operational logic.

@goruha goruha requested review from a team as code owners December 9, 2024 19:32
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request involve the deletion of an existing GitHub Actions workflow for website deployment and the introduction of new workflows for building, deploying, and destroying website previews. The new workflows enhance automation by refining triggers, permissions, and operational logic, ensuring that preview deployments function correctly, especially for pull requests from forked repositories.

Changes

File Path Change Summary
.github/workflows/website-deploy-preview.yml Deleted workflow for deploying website previews.
.github/workflows/website-preview-build.yml Added new workflow for building website previews, including steps for setup, build, and artifact upload.
.github/workflows/website-preview-deploy.yml Modified existing deployment workflow with updated names, triggers, environment variable references, and added steps for deployment initiation and status updates.
.github/workflows/website-preview-destroy.yml Updated destruction workflow with new permissions, trigger changes, job conditions, and additional steps for branch name extraction and environment deactivation.

Assessment against linked issues

Objective Addressed Explanation
Fix preview deployments for PRs from forked repositories (DEV-2677)

Possibly related issues

  • DEV-2677: The changes address the issue of fixing preview deployments for PRs from forked repositories by enhancing the deployment workflow.

Possibly related PRs

  • Upload build preview site as artifact #822: This PR is related as it involves modifications to the .github/workflows/website-deploy-preview.yml, which is directly connected to the deletion of that file in this PR.

Suggested labels

major

Suggested reviewers

  • johncblandii
  • jamengual
  • aknysh

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fbeaac8 and c839dea.

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

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. (Experiment)
  • @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: 3

🧹 Outside diff range and nitpick comments (2)
.github/workflows/website-preview-build.yml (1)

6-12: Consider adding paths-ignore for security

While you have paths filter for website/**, consider adding paths-ignore for sensitive paths like .github/workflows/** to prevent workflow modifications from triggering builds.

  pull_request:
    types:
      - opened
      - synchronize
      - reopened
    paths:
      - "website/**"
+   paths-ignore:
+     - ".github/workflows/**"
.github/workflows/website-preview-deploy.yml (1)

82-91: Consider adding error details to deployment status

The deployment status update could be more informative by including error details when the deployment fails.

      - name: Update deployment status
        uses: bobheadxi/deployments@648679e8e4915b27893bd7dbc35cb504dc915bc8 # v1
        if: always()
        with:
          step: finish
          status: ${{ job.status }}
          env: ${{ steps.deployment.outputs.env }}
          deployment_id: ${{ steps.deployment.outputs.deployment_id }}
          env_url: https://${{ env.DEPLOYMENT_HOST }}
          auto_inactive: true
+         description: ${{ job.status != 'success' && format('Deployment failed. Check the logs at {0}', github.server_url + '/' + github.repository + '/actions/runs/' + github.run_id) || 'Deployment successful' }}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 73c8c49 and fbeaac8.

📒 Files selected for processing (4)
  • .github/workflows/website-deploy-preview.yml (0 hunks)
  • .github/workflows/website-preview-build.yml (1 hunks)
  • .github/workflows/website-preview-deploy.yml (4 hunks)
  • .github/workflows/website-preview-destroy.yml (2 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/website-deploy-preview.yml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/website-preview-destroy.yml

49-49: shellcheck reported issue in this script: SC2086:info:1:41: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (4)
.github/workflows/website-preview-build.yml (1)

14-17: LGTM: Properly scoped permissions

The permissions are correctly minimized to only what's needed: write access for id-token and read access for contents.

.github/workflows/website-preview-destroy.yml (2)

51-57: Pin deployment action to specific commit hash

Good practice! The deployment action is correctly pinned to a specific commit hash 648679e8e4915b27893bd7dbc35cb504dc915bc8.


6-8: ⚠️ Potential issue

Security: Carefully review pull_request_target usage

Using pull_request_target runs workflows with repository secrets. Ensure no untrusted code from the PR is executed in this context.

✅ Verification successful

Let me check the actual content of the workflow file to verify how pull_request_target is being used.


The pull_request_target usage is secure in this workflow

The workflow is safely configured:

  • No checkout action is used, preventing access to untrusted PR code
  • Only trusted actions are used (aws-actions/configure-aws-credentials, bobheadxi/deployments)
  • Environment variables are properly referenced using GitHub context
  • The workflow performs cleanup operations using AWS CLI with proper OIDC authentication
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if workflow executes any code from PR
rg -l "actions/checkout|uses:" .github/workflows/website-preview-destroy.yml

Length of output: 124


Script:

#!/bin/bash
# Show the full content of the workflow file
cat .github/workflows/website-preview-destroy.yml

Length of output: 1966

.github/workflows/website-preview-deploy.yml (1)

54-59: LGTM: Secure GitHub App token implementation

Excellent implementation of GitHub App token for artifact download. This is more secure than using GITHUB_TOKEN as it provides fine-grained permissions.

Also applies to: 66-66

@goruha goruha merged commit 067a99f into main Dec 9, 2024
@goruha goruha deleted the decouple-preview-deployment branch December 9, 2024 20:44
@coderabbitai coderabbitai bot mentioned this pull request Dec 9, 2024
@github-actions
Copy link

These changes were released in v1.122.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