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

[workflows] Fix preview deployment inactivation #843

Merged
merged 2 commits into from
Dec 10, 2024

Conversation

goruha
Copy link
Member

@goruha goruha commented Dec 10, 2024

what

  • Deactivate preview env deployment only for the current branch

why

  • Allow to have deployment per PR

Summary by CodeRabbit

  • New Features
    • Introduced a conditional check to prevent deployment based on pull request labels.
    • Added a new step to seek deployment and set the environment to 'preview'.
    • Implemented a step to inactivate deployment based on the successful retrieval of a deployment ID.

@goruha goruha requested review from a team as code owners December 10, 2024 20:40
@goruha goruha requested review from Gowiem and gberenice December 10, 2024 20:40
Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

📝 Walkthrough

Walkthrough

The pull request modifies the GitHub Actions workflow file .github/workflows/website-preview-destroy.yml. Key changes include the addition of a conditional check to prevent deployment if the pull request has the label 'website-no-deploy', the introduction of a new step for seeking deployment, and the addition of an inactivation step for deployments. The AWS credentials configuration remains unchanged, and the deletion of the S3 bucket PR folder is retained.

Changes

File Change Summary
.github/workflows/website-preview-destroy.yml - Updated step from "mark environment as deactivated" to "Seek deployment".
- Added "Inactivate deployment" step.
- Conditional check added to prevent deployment if labeled 'website-no-deploy'.

Possibly related PRs

  • Refactor preview deployments workflows #836: Refactor preview deployments workflows - This PR modifies the .github/workflows/website-preview-destroy.yml file, which is directly related to the changes made in the main PR regarding the job steps and logic for the website destruction process.
  • Fix deployments overrides #841: Fix deployments overrides - This PR also updates the .github/workflows/website-preview-destroy.yml file by adding an override parameter to the mark environment as deactivated step, which is relevant to the changes in the main PR.

Suggested labels

no-release

Suggested reviewers

  • johncblandii
  • RoseSecurity
  • 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. (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: 0

🧹 Outside diff range and nitpick comments (3)
.github/workflows/website-preview-destroy.yml (3)

60-66: Use semantic versioning instead of commit hash

The deployment-status action is pinned to a specific commit hash. While this is secure, it makes it harder to track which version is being used. Consider using the semantic version tag v2.0.3 instead of 9a72af4586197112e0491ea843682b5dc280d806.

-        uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3
+        uses: chrnorm/[email protected]

51-59: Consider making the status parameter dynamic

The status: success parameter is hardcoded. Consider making this dynamic based on the actual state of the deployment or previous steps.

-          status: success
+          status: ${{ inputs.deployment_status || 'success' }}

51-66: Overall implementation looks good! 💪

The new deployment management steps effectively handle the PR objective of managing deployments per PR. The two-step process (seek and inactivate) provides a clean way to manage deployment states.

Consider adding error handling and logging to help debug deployment issues in production:

  1. Add step outputs for deployment status
  2. Include conditional steps for handling failed deployment lookups
  3. Add logging for important state changes
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 36a595e and 6351f50.

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

51-59: Consider using a more stable version of the seek-deployment action

The cloudposse/[email protected] is an early version (0.x.x), which might be unstable. Consider:

  1. Verifying if a newer, more stable version is available
  2. Adding a comment explaining why this specific version was chosen if it's intentional
✅ Verification successful

The action version is appropriate and actively maintained

The cloudposse/[email protected] is actually the latest version and the repository shows active maintenance with the most recent commit in September 2024. The version numbering, while early, appears intentional as the action maintains a focused, stable functionality. No open issues indicate stability concerns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for newer versions of the action
gh api repos/cloudposse/github-action-seek-deployment/releases --jq '.[].tag_name'

Length of output: 96


Script:

#!/bin/bash
# Let's check the action's repository for any issues or discussions about version stability
gh api repos/cloudposse/github-action-seek-deployment/issues --jq '.[] | select(.state=="open") | {title: .title, url: .html_url}'

# Also check the latest commit date to see if the project is actively maintained
gh api repos/cloudposse/github-action-seek-deployment/commits --jq '.[0] | {sha: .sha, date: .commit.author.date}'

Length of output: 330


51-59: Validate branch name before using it as deployment ref

The ref parameter uses the extracted branch name directly without validation. Consider adding input validation to ensure the branch name meets GitHub's requirements.

@osterman
Copy link
Member

@goruha I don't understand the description (please GPT!)

Just want to be clear, we are working on MANY parallel PRs and want previews for all of them, concurrently.

@goruha
Copy link
Member Author

goruha commented Dec 10, 2024

@osterman exactly

@goruha goruha merged commit b144ba2 into main Dec 10, 2024
28 checks passed
@goruha goruha deleted the fix-destroy-preview-environment branch December 10, 2024 20:51
@goruha goruha changed the title Fix deployments inactivate [workflows] Fix preview deployment inactivation Dec 10, 2024
Copy link

These changes were released in v1.123.0.

@coderabbitai coderabbitai bot mentioned this pull request Dec 19, 2024
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.

3 participants