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

ci: Add GH workflow to build app & deploy to GH Pages; Update demo link to point at GH Pages deployment. #114

Merged
merged 22 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
718bc34
Add workflow "Deploy to GitHub Pages".
junhaoliao Nov 9, 2024
1ea5633
Add line before uploading artifacts.
junhaoliao Nov 9, 2024
b395e12
Wrap strings with quotes.
junhaoliao Nov 9, 2024
5690e0d
Update demo link to use GitHub Pages.
junhaoliao Nov 9, 2024
b972057
Place comments before lines.
junhaoliao Nov 9, 2024
e546847
Add `id: "deployment"` into step.
junhaoliao Nov 9, 2024
e11f003
Reformat yaml.
junhaoliao Nov 9, 2024
88bf319
Fix yaml syntax.
junhaoliao Nov 9, 2024
3aea76c
Add `npm` caching.
junhaoliao Nov 9, 2024
6029019
Add name to the cache steps.
junhaoliao Nov 9, 2024
df4a275
test cache.
junhaoliao Nov 9, 2024
108ae1f
Use caching provided by actions/setup-node@v4.
junhaoliao Nov 9, 2024
1bb76c5
Change workflow name.
junhaoliao Nov 9, 2024
10c351c
Avoid spaces in braces - Apply suggestions from code review
junhaoliao Nov 9, 2024
5545ca2
Reformat - Apply suggestions from code review
junhaoliao Nov 9, 2024
6b31dcd
Capitalize first letter in comments - Apply suggestions from code review
junhaoliao Nov 9, 2024
a0ab914
Improve docs for `id-token: "write"` - Apply suggestions from code re…
junhaoliao Nov 9, 2024
dac2d1c
Rename deploy workflow file to use .yaml extension.
junhaoliao Nov 9, 2024
37911e7
Add `submodules: "recursive"` into "actions/checkout@v4".
junhaoliao Nov 9, 2024
ba82b3a
Enable job cancellation in deploy workflow.
junhaoliao Nov 9, 2024
5c46893
yaml: Add line before comment.
junhaoliao Nov 10, 2024
8bccb9a
Remove `actions: "write"` from GITHUB_TOKEN permission list.
junhaoliao Nov 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/deploy-gh-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "deploy-github-pages"

on:
push:
branches: ["main"]

Comment on lines +1 to +6
Copy link

@coderabbitai coderabbitai bot Nov 9, 2024

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add workflow concurrency control to prevent deployment conflicts.

To prevent race conditions when multiple workflow runs are triggered, add concurrency control:

name: "deploy-github-pages"

on:
  push:
    branches: ["main"]

+concurrency:
+  group: "pages"
+  cancel-in-progress: true
📝 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: "deploy-github-pages"
on:
push:
branches: ["main"]
name: "deploy-github-pages"
on:
push:
branches: ["main"]
concurrency:
group: "pages"
cancel-in-progress: true

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed a fix in commit ba82b3a, please review it.

Copy link

Choose a reason for hiding this comment

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

@junhaoliao, thank you for adding the concurrency control to the workflow. This should effectively prevent deployment conflicts. The fix looks good.


If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

permissions:
# So the workflow can cancel in-progress jobs
actions: "write"
Copy link
Member

Choose a reason for hiding this comment

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

This is my mistake in previous workflow PRs, but I found that this permission is not necessary for cancelling in-progress jobs. I think we should set these permissions to {} instead.

junhaoliao marked this conversation as resolved.
Show resolved Hide resolved

concurrency:
group: "${{github.workflow}}-${{github.ref}}"
# Cancel in-progress jobs for efficiency
junhaoliao marked this conversation as resolved.
Show resolved Hide resolved
junhaoliao marked this conversation as resolved.
Show resolved Hide resolved
cancel-in-progress: true

jobs:
build:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
with:
submodules: "recursive"

- uses: "actions/setup-node@v4"
with:
node-version: "22"
cache: "npm"
Comment on lines +23 to +26
Copy link

@coderabbitai coderabbitai bot Nov 9, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use LTS version of Node.js for production deployments.

Node.js v22 is currently in beta. For production deployments, use an LTS version:

      - uses: "actions/setup-node@v4"
        with:
-         node-version: "22"
+         node-version: "20"
          cache: "npm"
📝 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
- uses: "actions/setup-node@v4"
with:
node-version: "22"
cache: "npm"
- uses: "actions/setup-node@v4"
with:
node-version: "20"
cache: "npm"

Copy link
Member Author

Choose a reason for hiding this comment

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

Usage of "22" is intended.

Copy link

Choose a reason for hiding this comment

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

@junhaoliao, understood. I've noted that using Node.js version 22 is intended for this project.

(꒦_꒦)


✏️ Learnings added
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#114
File: .github/workflows/deploy-gh-pages.yaml:24-27
Timestamp: 2024-11-09T21:02:27.209Z
Learning: In the yscope-log-viewer project, specifically in the `.github/workflows/deploy-gh-pages.yaml` file, Node.js version 22 is intentionally used in GitHub Actions workflows.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

cache-dependency-path: "./package-lock.json"

- run: "npm install"

- run: "npm run build"

- name: "Upload static files as artifact"
uses: "actions/upload-pages-artifact@v3"
with:
path: "./dist"

deploy:
needs: "build"
permissions:
# To deploy to Pages
pages: "write"

# To request a JWT from GitHub for certifying the origin of the deployment
id-token: "write"
runs-on: "ubuntu-latest"
environment:
name: "github-pages"
url: "${{steps.deployment.outputs.page_url}}"
steps:
- name: "Deploy to GitHub Pages"
id: "deployment"
uses: "actions/deploy-pages@v4"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ See the docs in our [developer guide](docs/dev-guide).
[log4j1-appenders]: https://github.com/y-scope/log4j1-appenders
[logback-appenders]: https://github.com/y-scope/logback-appenders
[monaco-editor]: https://microsoft.github.io/monaco-editor/
[online-demo]: https://yscope.com/log-viewer?filePath=https://yscope.s3.us-east-2.amazonaws.com/sample-logs/yarn-ubuntu-resourcemanager-ip-172-31-17-135.log.1.clp.zst
[online-demo]: https://y-scope.github.io/yscope-log-viewer/?filePath=https://yscope.s3.us-east-2.amazonaws.com/sample-logs/yarn-ubuntu-resourcemanager-ip-172-31-17-135.log.1.clp.zst
[report-bug]: https://github.com/y-scope/yscope-log-viewer/issues/new?labels=bug&template=bug-report.yml
[request-feature]: https://github.com/y-scope/yscope-log-viewer/issues/new?labels=enhancement&template=feature-request.yml
[zulip]: https://yscope-clp.zulipchat.com/
Expand Down
Loading