Skip to content

ci: fix auto deploy site failed #2616

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

Closed
wants to merge 1 commit into from
Closed

ci: fix auto deploy site failed #2616

wants to merge 1 commit into from

Conversation

kagol
Copy link
Member

@kagol kagol commented Dec 5, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Introduced a new environment configuration file to define application settings, including context, build target, and URLs for testing.
  • Improvements

    • Enhanced auto-deployment workflow for the site, including updated permissions and action versions for better performance and reliability.
    • Updated build script to specify a mode, potentially improving the build process.

These changes aim to streamline deployment and enhance the configuration experience for users.

@kagol kagol added the ci CI/CD (流水线持续集成) label Dec 5, 2024
Copy link

coderabbitai bot commented Dec 5, 2024

Walkthrough

The pull request introduces several updates to the auto-deployment workflow and environment configuration for a project. Key changes include modifications to permissions in the workflow file, updates to multiple action versions, and the addition of a new environment configuration file. The build command in the package.json has also been altered to specify a mode. These changes collectively enhance the deployment process and define the environment settings for the application.

Changes

File Path Change Summary
.github/workflows/auto-deploy-site.yml Updated permissions for build job, simplified Install deps, set NODE_OPTIONS, upgraded action versions, added steps for directory permissions and file copying, updated Upload artifact, and moved environment declaration.
examples/sites/env/.env.pages Introduced new environment configuration file with variables: VITE_CONTEXT, VITE_BUILD_TARGET, VITE_APP_MODE, VITE_APP_BUILD_BASE_URL, VITE_PLAYGROUND_URL.
examples/sites/package.json Modified build script from "build": "vite build" to "build": "vite build --mode pages".

Possibly related PRs

  • ci: add auto deploy site #2582: This PR introduces a new GitHub Actions workflow for auto-deploying the site, which is directly related to the modifications made in the main PR to the .github/workflows/auto-deploy-site.yml file, including updates to permissions and action versions.
  • ci(build): fix theme concat error #2145: Although primarily focused on fixing a theme concatenation error, this PR modifies the package.json file, which is relevant to the build process mentioned in the main PR, indicating a connection to the overall deployment and build configuration.

Suggested reviewers

  • zzcr

🐰 In the meadow, changes bloom,
With workflows bright, we clear the gloom.
New scripts and settings, all in place,
Our project hops with joyful grace!
Let the builds run, let the pages flow,
For every change, our spirits grow! 🌼


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

ci: set --max-old-space-size

ci: add .env.pages

fix: fix deploy fail
@kagol kagol force-pushed the kagol/auto-deploy-site branch from f5e2697 to 0bacaae Compare December 5, 2024 09:33
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
.github/workflows/auto-deploy-site.yml (1)

59-62: Add newline at end of file

The deployment configuration looks good, but please add a newline at the end of the file to comply with YAML best practices.

       url: ${{ steps.deployment.outputs.page_url }}
+
🧰 Tools
🪛 yamllint (1.35.1)

[error] 62-62: no new line character at the end of file

(new-line-at-end-of-file)

🛑 Comments failed to post (1)
.github/workflows/auto-deploy-site.yml (1)

46-48: ⚠️ Potential issue

Security: Restrict directory permissions

The chmod 777 command grants full read/write/execute permissions to all users, which is overly permissive. Consider using more restrictive permissions.

-      - run: sudo chmod -R 777 ./dist
+      - run: sudo chmod -R 755 ./dist
📝 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.

      - run: sudo chmod -R 755 ./dist
      - run: cp ./examples/sites/dist/assets/_commonjsHelpers*.js ./_site/assets
      - run: cp ./_site/index.html ./_site/404.html

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

🧹 Outside diff range and nitpick comments (2)
.github/workflows/auto-deploy-site.yml (2)

38-38: Investigate root cause of memory issues

While increasing the Node.js memory limit might resolve the immediate issue, it's important to investigate why the build process requires such a large amount of memory.

Consider:

  1. Analyzing the build process for memory leaks
  2. Implementing incremental builds
  3. Optimizing asset bundling and processing

Would you like assistance in profiling the build process to identify memory-intensive operations?


60-62: Add newline at end of file

Add a newline character at the end of the file to comply with POSIX standards and avoid potential issues with text processing tools.

   environment:
     name: github-pages
-    url: ${{ steps.deployment.outputs.page_url }}
+    url: ${{ steps.deployment.outputs.page_url }}
+
🧰 Tools
🪛 yamllint (1.35.1)

[error] 62-62: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f5e2697 and 0bacaae.

📒 Files selected for processing (3)
  • .github/workflows/auto-deploy-site.yml (2 hunks)
  • examples/sites/env/.env.pages (1 hunks)
  • examples/sites/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/sites/package.json
  • examples/sites/env/.env.pages
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/auto-deploy-site.yml

[error] 62-62: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (2)
.github/workflows/auto-deploy-site.yml (2)

26-27: Verify the necessity of write permissions

The addition of contents: write permissions at the job level overrides the more restrictive root-level permissions. While this might be needed for the new file operations, it's generally recommended to follow the principle of least privilege.

Let's verify if these permissions are strictly necessary:

✅ Verification successful

Write permissions are necessary for the workflow operations

The workflow requires write permissions as it performs file operations including:

  • Modifying file permissions with chmod
  • Copying files with cp operations
  • Uploading artifacts using actions/upload-pages-artifact

These operations, particularly the file modifications and artifact uploads, require write access to the repository contents.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any git operations or file modifications in the workflow
rg -A 5 "git |checkout|commit|push|chmod|cp|mv" .github/workflows/auto-deploy-site.yml

Length of output: 635


40-40: Verify compatibility of major action version updates

Multiple actions have been updated to newer major versions:

  • configure-pages: v2 → v5
  • upload-pages-artifact: v1 → v3
  • deploy-pages: v1 → v4

These major version jumps might introduce breaking changes.

Let's verify the compatibility:

Also applies to: 50-50, 59-59

✅ Verification successful

Version updates are compatible and safe to use

Based on the release notes:

  • configure-pages@v5: Breaking changes only affect Next.js configurations, which isn't used in this workflow
  • upload-pages-artifact@v3: No breaking changes in latest release (v3.0.1)
  • deploy-pages@v4: No breaking changes in latest release (v4.0.5)

The workflow structure is simple with a single dependency chain (deploy needs build), and all actions are being used according to their latest stable versions. The updates are safe to proceed with.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any other actions in the workflow that might need updates
rg "uses: actions/" .github/workflows/auto-deploy-site.yml

# Check if these actions are used in other workflow files
fd -e yml -e yaml . .github/workflows/ --exec rg "actions/(configure|upload|deploy)-pages@"

Length of output: 437


Script:

#!/bin/bash
# Let's check the changelog or release notes for these actions in their respective repositories
gh api repos/actions/configure-pages/releases/latest
gh api repos/actions/upload-pages-artifact/releases/latest
gh api repos/actions/deploy-pages/releases/latest

# Also check if there are any other dependencies on these actions
rg -A 2 -B 2 "needs:" .github/workflows/auto-deploy-site.yml

Length of output: 8931

Comment on lines +46 to +48
- run: sudo chmod -R 777 ./dist
- run: cp ./examples/sites/dist/assets/_commonjsHelpers*.js ./_site/assets
- run: cp ./_site/index.html ./_site/404.html
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security and architectural concerns in file operations

Several concerns with the new file operations:

  1. Using chmod 777 is overly permissive and a security risk
  2. Manual file copying might indicate build configuration issues
  3. Duplicating index.html as 404.html could be handled more elegantly

Consider these alternatives:

  1. Use more restrictive permissions: chmod 644 for files and chmod 755 for directories
  2. Configure the build process to output files in the correct location
  3. Handle 404 pages through proper routing configuration

Would you like assistance in implementing any of these improvements?

@@ -31,27 +33,30 @@
with:
version: 9
- name: Install deps
run: pnpm -F @opentiny/vue-docs i --no-frozen-lockfile
run: pnpm i --no-frozen-lockfile
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider scoping dependency installation

The removal of the package filter -F @opentiny/vue-docs means all dependencies will be installed, which could increase build time and resource usage unnecessarily.

Consider using a more targeted installation:

-run: pnpm i --no-frozen-lockfile
+run: pnpm i --no-frozen-lockfile -F @opentiny/vue-docs... 
📝 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
run: pnpm i --no-frozen-lockfile
run: pnpm i --no-frozen-lockfile -F @opentiny/vue-docs...

@kagol kagol closed this Dec 5, 2024
@kagol kagol deleted the kagol/auto-deploy-site branch April 14, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci CI/CD (流水线持续集成)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant