Skip to content

add gh deploy script for any dev#74

Merged
jmoraispk merged 7 commits intomainfrom
joaom/deploy
Feb 19, 2026
Merged

add gh deploy script for any dev#74
jmoraispk merged 7 commits intomainfrom
joaom/deploy

Conversation

@jmoraispk
Copy link
Owner

No description provided.

@vercel
Copy link

vercel bot commented Feb 19, 2026

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

Project Deployment Actions Updated (UTC)
loglife Ready Ready Preview, Comment Feb 19, 2026 8:00pm

@greptile-apps
Copy link

greptile-apps bot commented Feb 19, 2026

Greptile Summary

This PR adds a GitHub Actions workflow to automatically deploy preview environments for pull requests. When a PR is opened or updated, the workflow SSHs into a server and deploys the website to a preview environment using PM2.

Critical Issues:

  • All PRs share the same deployment directory (/opt/loglife/preview), port (3001), and PM2 app name (loglife-preview), causing conflicts when multiple PRs are open
  • Concurrency group doesn't include PR number, so different PRs cancel each other's deployments
  • No error handling - deployment will continue even if build fails

Recommendations:

  • Use PR-specific resources: append PR number to directory paths, app names, and calculate unique ports
  • Update concurrency group to deploy-preview-${{ github.event.pull_request.number }}
  • Add set -e to fail fast on errors

Confidence Score: 2/5

  • This PR has critical logic issues that will cause conflicts when multiple PRs are deployed simultaneously
  • The workflow shares the same deployment directory, app name, and port across all PRs, causing deployments to overwrite each other. The concurrency group is also too broad, canceling unrelated PR deployments.
  • .github/workflows/deploy.yml requires attention to fix resource isolation between different PR deployments

Important Files Changed

Filename Overview
.github/workflows/deploy.yml Adds PR preview deployment workflow, but has critical issues with shared resources causing conflicts between multiple PRs

Sequence Diagram

sequenceDiagram
    participant GH as GitHub Actions
    participant SSH as SSH Connection
    participant Server as Deploy Server
    participant Git as Git Repository
    participant PM2 as PM2 Process Manager

    GH->>SSH: Connect via appleboy/ssh-action
    SSH->>Server: Execute deployment script
    Server->>Server: Load NVM environment
    
    alt Directory doesn't exist
        Server->>Git: git clone repository
    end
    
    Server->>Git: git fetch origin
    Server->>Server: git checkout branch
    Server->>Server: git reset --hard origin/branch
    Server->>Server: cd website
    Server->>Server: pnpm install --frozen-lockfile
    Server->>Server: pnpm run build
    Server->>PM2: pm2 delete old app (if exists)
    Server->>PM2: pm2 start new app on PORT 3001
    Server->>PM2: pm2 save
    SSH-->>GH: Deployment complete
Loading

Last reviewed commit: 0f858f4

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 12 to 14
concurrency:
group: deploy-preview
cancel-in-progress: true
Copy link

Choose a reason for hiding this comment

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

Concurrency group should include PR number to prevent different PRs from canceling each other's deployments

Suggested change
concurrency:
group: deploy-preview
cancel-in-progress: true
concurrency:
group: deploy-preview-${{ github.event.pull_request.number }}
cancel-in-progress: true

Comment on lines 31 to 33
DEPLOY_DIR=/opt/loglife/preview
APP_NAME=loglife-preview
PORT=3001
Copy link

Choose a reason for hiding this comment

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

All PRs share the same deploy directory, port, and app name, causing conflicts when multiple PRs are open

Suggested change
DEPLOY_DIR=/opt/loglife/preview
APP_NAME=loglife-preview
PORT=3001
DEPLOY_DIR=/opt/loglife/preview-${{ github.event.pull_request.number }}
APP_NAME=loglife-preview-${{ github.event.pull_request.number }}
PORT=$((3000 + ${{ github.event.pull_request.number }}))

cd "$DEPLOY_DIR"
git fetch origin
git checkout "$BRANCH"
git reset --hard "origin/$BRANCH"
Copy link

Choose a reason for hiding this comment

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

git reset --hard will discard any uncommitted changes or failed deployment artifacts without verification

Comment on lines +46 to +47
pnpm install --frozen-lockfile
pnpm run build
Copy link

Choose a reason for hiding this comment

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

Add error handling to prevent starting the server if build fails - consider adding set -e at the start of the script

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@jmoraispk jmoraispk merged commit 7e8428e into main Feb 19, 2026
5 checks passed
@jmoraispk jmoraispk deleted the joaom/deploy branch February 19, 2026 20:01
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.

1 participant