Skip to content

chore(workflows): Fix production release setup - #301

Merged
vprashrex merged 1 commit into
mainfrom
fix/prod-deploy-nvm
Oct 30, 2026
Merged

vprashrex merged 1 commit into
mainfrom
fix/prod-deploy-nvm

Conversation

@vprashrex

@vprashrex vprashrex commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Closes #300

Summary

  • Fix production release failure due to npm: command not found.
  • Align remote command in .github/workflows/create-release.yml with deploy-staging.yml:
    • Set ROOT_USER: ${{ secrets.USER }} with guard for missing secret.
    • Export HOME=/home/$ROOT_USER for global git config.
    • Set up NVM with export NVM_DIR=/home/$ROOT_USER/.nvm && . $NVM_DIR/nvm.sh for correct node and npm access.
    • Use sudo -iu $ROOT_USER pm2 restart $APP_NAME to restart the app under the deploy user's pm2.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran npm run dev and npm run build in the repository root and test.
  • If you've fixed a bug or added code that is tested
Original PR description

Issue

Closes #300

Summary

The v0.6.1 production release failed with npm: command not found (exit 127). #299 fixed the $HOME not set error by running as root with HOME=/root. Git now gets through fetch and checkout, but on the production host node is installed through NVM under the deploy user, so root has no npm. The app also runs in that user's pm2, so a root pm2 restart would fail next.

This PR makes the production remote command in .github/workflows/create-release.yml the same as deploy-staging.yml, which deploys fine. It also matches what production ran before #292:

  • ROOT_USER: ${{ secrets.USER }}, with a guard if the secret is missing. USER already exists in the AWS_ENV environment.
  • export HOME=/home/$ROOT_USER: git --global config still works.
  • export NVM_DIR=/home/$ROOT_USER/.nvm && . $NVM_DIR/nvm.sh: gives npm ci / npm run build the right node and npm.
  • sudo -iu $ROOT_USER pm2 restart $APP_NAME: restarts the app in the deploy user's pm2.

Checklist

  • Ran npm run dev and npm run build in the repository root and test.
  • If you've fixed a bug or added code that is tested

Notes

  • Workflow-only change; the YAML parses. The remote command is line-for-line identical to deploy-staging.yml. It can only be fully tested by a real release run.
  • Production is still serving v0.5.0. The server repo is checked out at 7c29ec6, but .next is the old build and pm2 was not restarted, so nothing user-facing changed.
  • After merging, cut v0.6.2. Re-running v0.6.1 uses the workflow file from that tag's commit and would fail the same way.

With HOME=/root the production deploy got past git but failed at npm ci
with "npm: command not found": node is installed through NVM under the
deploy user, not system-wide, and the app runs in that user's pm2.
Use the same remote command as deploy-staging.yml: export HOME for the
deploy user, load NVM from their home, and restart pm2 as that user.

Closes #300
@vprashrex vprashrex added the bug Something isn't working label Oct 30, 2026
@vprashrex vprashrex self-assigned this Oct 30, 2026
@vprashrex
vprashrex requested a review from Ayush8923 October 30, 2026 07:09
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1
  • ready-for-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions github-actions Bot changed the title fix(deployment): Load NVM and restart pm2 as deploy user in production chore(workflows): Fix production release setup Oct 30, 2026
@vprashrex
vprashrex merged commit 30d8484 into main Oct 30, 2026
3 checks passed
@vprashrex
vprashrex deleted the fix/prod-deploy-nvm branch October 30, 2026 07:12
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.6.2-main.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working released on @main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deployment: Fix npm command issue

2 participants