standard CI/CD issue #182346
-
Why are you starting this discussion?Question What GitHub Actions topic or product is this about?General Discussion DetailsMy React + TypeScript app is finished and already stored in a GitHub repo. I also have an online hosting account ready, but the live environment and a staging area still need to be wired to the repo. What I need from you is a clean Git-based workflow that lets me: • push to a branch and have the code automatically built and published to a private staging sub-domain, • merge to the main branch and see it land on the production site—no manual uploads. Because GitHub is the VCS and GitHub Actions is the preferred deployment method, the job centres on creating one or more workflow files that: 1. install dependencies, run the TypeScript build, and bundle the React app; 2. deploy the build output over SSH, rsync, or any other method that suits the server; 3. keep staging and production environments clearly separated through branches, secrets, or environment variables. Acceptance criteria • A successful run on the staging branch builds and serves the latest commit on the staging URL. • A successful run on main does the same for production. • Workflows, environment files, and concise setup notes are committed to the repo so I can extend or tweak them later. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Only staging and main trigger deployments.
On your server: /var/www/ Your web server (Nginx/Apache) points each domain to its respective current folder.
Add once, reused by workflows: Secret name Description 🔐 Important: Use a deploy-only SSH key Public key goes in ~/.ssh/authorized_keys on server
Commit non-secret defaults: .env.staging Example: .env.stagingVITE_API_BASE_URL=https://api.staging.example.com .env.productionVITE_API_BASE_URL=https://api.example.com
Create: .github/workflows/deploy.yml ✅ Single workflow, branch-aware, clean on: jobs:
✔ Push to staging Dependencies installed TypeScript + React built Output deployed to staging subdomain automatically ✔ Merge to main Same pipeline Clean deployment to production No manual uploads ✔ Clear environment separation Branch-based deploy Separate .env files Separate server paths Secrets isolated in GitHub ✔ Extensible Easy to add tests, linting, Slack notifications, cache, rollbacks
You can extend later with: npm run lint && npm run test before build rsync --link-dest for atomic deploys GitHub Environments with approvals for production Post-deploy health check (curl)
Deployment
Secrets are configured in GitHub repository settings. Final Verdict ✅ Yes — this fully satisfies the client’s requirement |
Beta Was this translation helpful? Give feedback.
main → production (example.com)
staging → staging (staging.example.com)
feature/* → no deploy
Only staging and main trigger deployments.
On your server:
/var/www/
├── app-staging/
│ └── current/
└── app-production/
└── current/
Your web server (Nginx/Apache) points each domain to its respective current folder.
Add once, reused by workflows:
Secret name Description
SSH_HOST Server IP or hostname
SSH_USER SSH username
SSH_PRIVATE_KEY Private key (no passphrase)
STAGING_PATH /var/www/app-staging/current
PRODUCTION_PATH /var/www/app-production/current
🔐 Important:
Use a deploy-only SSH…