Skip to content

Create npm-publish.yml#12

Merged
Huynhthuongg merged 9 commits into
mainfrom
Huynhthuongg-patch-2
May 19, 2026
Merged

Create npm-publish.yml#12
Huynhthuongg merged 9 commits into
mainfrom
Huynhthuongg-patch-2

Conversation

@Huynhthuongg

@Huynhthuongg Huynhthuongg commented May 3, 2026

Copy link
Copy Markdown
Member

Open in Devin Review

Summary by cubic

Add CI to publish the package to npm and GitHub Packages on release, run Webpack builds on push/PR, manage Terraform plans/applies, and switch Vercel Web Analytics to the recommended script tag.

  • New Features

    • Publishing: adds .github/workflows/npm-publish.yml (Node 20 build + tests, releases to npm with secrets.npm_token) and .github/workflows/npm-publish-github-packages.yml (releases to GitHub Packages with GITHUB_TOKEN); both trigger on release creation after build.
    • CI/Infra: adds Webpack build matrix for Node 18/20/22 on push/PR and Terraform init/fmt/plan on PRs with apply on push to main; updates public/index.html to use <script defer src="/_vercel/insights/script.js"></script>.
  • Migration

    • Add repo secrets: npm_token and TF_API_TOKEN.
    • Enable Vercel Web Analytics in the dashboard.

Written for commit 44fb568. Summary will update on new commits. Review in cubic

Signed-off-by: Huỳnh Thương <admin@huynhthuong.online>
@vercel

vercel Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
claude-open-ai Ready Ready Preview, Comment May 19, 2026 10:37am

@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Tổng quan

Thêm quy trình GitHub Actions mới .github/workflows/npm-publish.yml tự động hóa việc xuất bản gói npm tới GitHub Packages khi có Release. Quy trình chạy kiểm thử trước khi công bố.

Thay đổi

Tự động hóa xuất bản npm

Lớp / Tệp Tóm tắt
Cấu hình quy trình xuất bản
.github/workflows/npm-publish.yml
Quy trình GitHub Actions được kích hoạt trên sự kiện release. Chạy công việc xây dựng để kiểm tra phụ thuộc và chạy kiểm thử, rồi công việc xuất bản thực thi npm publish với xác thực từ secrets.npm_token.

Ước tính nỗ lực kiểm tra mã

🎯 2 (Đơn giản) | ⏱️ ~8 phút

Bài thơ

🐰 Một quy trình mới sinh ra,
Khi Release được tạo thì nó chạy,
Kiểm thử trước, xuất bản sau,
npm Package lên trời xanh bay,
Tự động hóa—phép thuật đơn sơ!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Tiêu đề chính xác mô tả thay đổi chính trong pull request - thêm tệp npm-publish.yml.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description accurately describes the changeset, detailing the addition of GitHub Actions workflows for npm publishing, CI/CD pipelines, and infrastructure updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Huynhthuongg-patch-2
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch Huynhthuongg-patch-2
  • 🛠️ Aethon

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped Aethon/backend-api.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread .github/workflows/npm-publish.yml

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a92cac9f50

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

with:
node-version: 20
- run: npm ci
- run: npm test

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Guard npm test when no test script exists

This workflow always runs npm test, but package.json only defines start and dev scripts, so npm test exits with Missing script: "test" in this repository. Because publish-npm depends on build, every release-triggered run will fail before publishing, making the new publish pipeline non-functional unless a test script is added or the step uses npm test --if-present.

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".github/workflows/npm-publish.yml">

<violation number="1" location=".github/workflows/npm-publish.yml:8">
P1: Using `release.types: [created]` can skip publishing for releases that are published from drafts. Trigger on `published` so npm publish runs on real release publication.</violation>

<violation number="2" location=".github/workflows/npm-publish.yml:19">
P1: `npm test` will fail because `package.json` does not define a `test` script (only `start` and `dev` exist). This causes the `build` job to always fail, and since `publish-npm` depends on `build`, the entire publish pipeline is non-functional. Use `npm test --if-present` to skip gracefully when no test script is defined.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread .github/workflows/npm-publish.yml
Comment thread .github/workflows/npm-publish.yml
@Huynhthuongg Huynhthuongg enabled auto-merge (squash) May 18, 2026 10:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c330804eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


on:
release:
types: [created]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Trigger publishing when releases are published

For releases prepared as drafts in the GitHub UI and then published, this workflow never runs: GitHub's release-event docs state that created, edited, and deleted do not trigger workflows for draft releases, and recommend published when you want workflows to run as releases publish. Since this is the only npm publish trigger, any release created through the common draft-then-publish flow will be skipped entirely.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/npm-publish.yml:
- Around line 1-2: The workflow header comment incorrectly states it will
"publish ... to GitHub Packages" while the actual configuration targets
https://registry.npmjs.org/; update the top comment in
.github/workflows/npm-publish.yml (the initial workflow description lines) to
accurately state that the package is published to the npm registry (or, if the
intent is GitHub Packages, change the registry configuration to GitHub Packages)
so the comment and actual registry (https://registry.npmjs.org/) are consistent.
- Around line 10-33: Add an explicit minimal permissions block to the workflow
so it only has repository read access; update the top-level workflow (affecting
the jobs "build" and "publish-npm") to include permissions: contents: read so
the checkout step and subsequent actions run with least privilege instead of
relying on repo default permissions.
- Around line 7-8: The workflow currently listens to the GitHub Actions
'release' event with types: [created], which triggers on drafts and can publish
to npm too early; change the event types value from types: [created] to types:
[published] on the 'release' trigger and add a guard to skip prereleases (e.g.,
check github.event.release.prerelease is false or similar) so the npm-publish
workflow only runs when a release is publicly published and not for
prerelease/draft releases.
- Around line 31-33: The workflow currently uses a static secret
(NODE_AUTH_TOKEN) for npm publish; switch to GitHub OIDC Trusted Publishing by
updating your actions/setup-node step to use node-version 24.x (ensure npm
11.5.1+), remove the ENV NODE_AUTH_TOKEN from the "npm publish" run step, add
repository permissions to allow id-token issuance (permissions: id-token: write
and packages: write if publishing packages), and change the "npm publish"
invocation to use the OIDC-backed setup-node authentication (include
--provenance when publishing). Locate the actions/setup-node configuration and
the "npm publish" run step to make these changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 646d793b-0b64-4ef3-a5a5-73ba63d50a13

📥 Commits

Reviewing files that changed from the base of the PR and between 529fa33 and 5c33080.

📒 Files selected for processing (1)
  • .github/workflows/npm-publish.yml

Comment thread .github/workflows/npm-publish.yml
Comment thread .github/workflows/npm-publish.yml
Comment thread .github/workflows/npm-publish.yml
Comment thread .github/workflows/npm-publish.yml
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 18, 2026
@Huynhthuongg Huynhthuongg enabled auto-merge (squash) May 18, 2026 10:35
@Huynhthuongg Huynhthuongg disabled auto-merge May 18, 2026 17:41
@Huynhthuongg Huynhthuongg linked an issue May 18, 2026 that may be closed by this pull request
@Huynhthuongg Huynhthuongg linked an issue May 19, 2026 that may be closed by this pull request
vercel Bot and others added 6 commits May 19, 2026 17:28
# Vercel Web Analytics Implementation Report

## Summary
Successfully configured Vercel Web Analytics for the claude-openai project following the latest official Vercel documentation.

## Project Details
- **Framework**: Node.js/Express serving static HTML files
- **Package Manager**: npm
- **Project Type**: Backend API with static frontend (public/index.html)

## Changes Made

### Modified Files
1. **public/index.html**
   - Updated Vercel Web Analytics implementation to use the recommended script tag approach
   - Changed from: ESM import using CDN (`import { inject } from 'https://cdn.jsdelivr.net/npm/@vercel/analytics@2/+esm'`)
   - Changed to: Recommended script tag approach (`<script defer src="/_vercel/insights/script.js"></script>`)
   - This follows the official Vercel documentation for HTML5 projects

### Package Information
- **@vercel/analytics**: Version 2.0.1 (already installed)
- **@vercel/speed-insights**: Version 2.0.0 (already installed)

## Implementation Details

According to the latest Vercel documentation (fetched on 2026-04-28):
- For static HTML projects, the recommended approach is to use the script tag: `<script defer src="/_vercel/insights/script.js"></script>`
- This script is automatically served by Vercel after enabling Web Analytics in the dashboard
- The implementation is placed before the closing `</body>` tag for optimal performance

## Configuration Steps Followed
1. ✅ Fetched latest Vercel Analytics documentation from https://vercel.com/docs/analytics/quickstart
2. ✅ Identified project framework (Node.js/Express with static HTML)
3. ✅ Verified @vercel/analytics package was already installed (v2.0.1)
4. ✅ Updated the analytics implementation in public/index.html to use the recommended script tag
5. ✅ Ran npm install to ensure dependencies and lock files are up to date
6. ✅ Tested server startup and verified HTML is served correctly
7. ✅ Verified the analytics script tag is present in the served HTML

## Testing Results
- ✅ Server starts successfully on port 3000
- ✅ Static HTML file is served correctly
- ✅ Analytics script tag is properly included in the HTML output
- ✅ No build errors or warnings
- ✅ Dependencies installed successfully with 0 vulnerabilities

## Next Steps for Activation
To activate Vercel Web Analytics:
1. Navigate to the project's Analytics section in the Vercel dashboard
2. Click the "Enable" button to activate Web Analytics
3. Deploy the project to Vercel
4. After deployment, analytics data will begin collecting automatically
5. View analytics in the Vercel dashboard (data appears within days of deployment)

## Notes
- The project already had @vercel/analytics and @vercel/speed-insights installed
- The previous implementation used an ESM CDN import, which has been replaced with the official Vercel-served script
- The new implementation follows Vercel's recommended best practices for HTML5 projects
- Speed Insights was already properly configured and remains unchanged

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
This workflow runs tests and publishes a Node.js package to GitHub
Packages upon release creation.

Signed-off-by: Huỳnh Thương <admin@huynhthuong.online>
Signed-off-by: Huỳnh Thương <admin@huynhthuong.online>
This workflow builds and deploys a Node.js application to Azure Web App on push to the main branch.

Signed-off-by: Huỳnh Thương <admin@huynhthuong.online>
This workflow installs Terraform CLI and configures it with an API token for Terraform Cloud. It runs `terraform init`, `terraform fmt`, and `terraform plan` on pull requests, and `terraform apply` on pushes to the main branch.

Signed-off-by: Huỳnh Thương <admin@huynhthuong.online>
@kilo-code-bot

kilo-code-bot Bot commented May 19, 2026

Copy link
Copy Markdown

Kilo Code Review could not run — your account is out of credits.

Add credits or switch to a free model to enable reviews on this change.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15dfa4f168

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/webpack.yml
Comment thread .github/workflows/terraform.yml
Comment thread .github/workflows/npm-publish-github-packages.yml
Comment thread .github/workflows/npm-publish-github-packages.yml

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

4 issues found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".github/workflows/npm-publish-github-packages.yml">

<violation number="1" location=".github/workflows/npm-publish-github-packages.yml:34">
P2: GitHub Packages only supports scoped npm packages (format `@NAMESPACE/PACKAGE-NAME`). Publishing an unscoped package to `https://npm.pkg.github.com/` will be rejected. The package name in `package.json` needs to be scoped (e.g., `@owner/claude-openai`) or the registry URL should be changed.</violation>
</file>

<file name=".github/workflows/terraform.yml">

<violation number="1" location=".github/workflows/terraform.yml:87">
P1: This workflow runs `terraform plan` even though the repository has no Terraform configuration files, so CI will fail when the job executes.</violation>

<violation number="2" location=".github/workflows/terraform.yml:92">
P2: The branch check in the `Terraform Apply` condition is malformed (`refs/heads/"main"`), so apply is effectively disabled.</violation>
</file>

<file name=".github/workflows/webpack.yml">

<violation number="1" location=".github/workflows/webpack.yml:28">
P1: `npx webpack` will not work correctly: the project has no webpack dependency and no webpack configuration file. This will either fail at runtime or produce a broken build. Use a project-specific build script or define the proper build toolchain.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


# Generates an execution plan for Terraform
- name: Terraform Plan
run: terraform plan -input=false

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: This workflow runs terraform plan even though the repository has no Terraform configuration files, so CI will fail when the job executes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/terraform.yml, line 87:

<comment>This workflow runs `terraform plan` even though the repository has no Terraform configuration files, so CI will fail when the job executes.</comment>

<file context>
@@ -0,0 +1,93 @@
+
+    # Generates an execution plan for Terraform
+    - name: Terraform Plan
+      run: terraform plan -input=false
+
+      # On push to "main", build or change infrastructure according to Terraform configuration files
</file context>

- name: Build
run: |
npm install
npx webpack

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: npx webpack will not work correctly: the project has no webpack dependency and no webpack configuration file. This will either fail at runtime or produce a broken build. Use a project-specific build script or define the proper build toolchain.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/webpack.yml, line 28:

<comment>`npx webpack` will not work correctly: the project has no webpack dependency and no webpack configuration file. This will either fail at runtime or produce a broken build. Use a project-specific build script or define the proper build toolchain.</comment>

<file context>
@@ -0,0 +1,28 @@
+    - name: Build
+      run: |
+        npm install
+        npx webpack
</file context>

# On push to "main", build or change infrastructure according to Terraform configuration files
# Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks
- name: Terraform Apply
if: github.ref == 'refs/heads/"main"' && github.event_name == 'push'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The branch check in the Terraform Apply condition is malformed (refs/heads/"main"), so apply is effectively disabled.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/terraform.yml, line 92:

<comment>The branch check in the `Terraform Apply` condition is malformed (`refs/heads/"main"`), so apply is effectively disabled.</comment>

<file context>
@@ -0,0 +1,93 @@
+      # On push to "main", build or change infrastructure according to Terraform configuration files
+      # Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks
+    - name: Terraform Apply
+      if: github.ref == 'refs/heads/"main"' && github.event_name == 'push'
+      run: terraform apply -auto-approve -input=false
</file context>
Suggested change
if: github.ref == 'refs/heads/"main"' && github.event_name == 'push'
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

node-version: 20
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: GitHub Packages only supports scoped npm packages (format @NAMESPACE/PACKAGE-NAME). Publishing an unscoped package to https://npm.pkg.github.com/ will be rejected. The package name in package.json needs to be scoped (e.g., @owner/claude-openai) or the registry URL should be changed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/npm-publish-github-packages.yml, line 34:

<comment>GitHub Packages only supports scoped npm packages (format `@NAMESPACE/PACKAGE-NAME`). Publishing an unscoped package to `https://npm.pkg.github.com/` will be rejected. The package name in `package.json` needs to be scoped (e.g., `@owner/claude-openai`) or the registry URL should be changed.</comment>

<file context>
@@ -0,0 +1,36 @@
+          node-version: 20
+          registry-url: https://npm.pkg.github.com/
+      - run: npm ci
+      - run: npm publish
+        env:
+          NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
</file context>

@Huynhthuongg Huynhthuongg merged commit 3eb9639 into main May 19, 2026
4 of 11 checks passed
@Huynhthuongg Huynhthuongg deleted the Huynhthuongg-patch-2 branch May 19, 2026 10:39
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.

Toàn quyền điều khiển Agents/code

1 participant