Skip to content

Commit c758cb8

Browse files
authored
Merge pull request #1 from Orbiton-labs/feat/ci-cd
feat: add deployment guide and GitHub Actions workflows
2 parents 76c2bdd + 04e9487 commit c758cb8

File tree

7 files changed

+284
-1
lines changed

7 files changed

+284
-1
lines changed

.github/workflows/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Vercel Deployment Workflows
2+
3+
This project uses GitHub Actions to deploy to Vercel based on tags and releases instead of the default branch-based deployments.
4+
5+
## Setup Instructions
6+
7+
### 1. Vercel CLI Setup
8+
9+
To configure the project for tag-based deployments:
10+
11+
1. Install Vercel CLI locally:
12+
```bash
13+
pnpm add --global vercel
14+
```
15+
16+
2. Log in to Vercel:
17+
```bash
18+
vercel login
19+
```
20+
21+
3. Link your project:
22+
```bash
23+
vercel link
24+
```
25+
26+
4. This will create a `.vercel` directory with a `project.json` file containing your `orgId` and `projectId`
27+
28+
### 2. GitHub Secrets Setup
29+
30+
Add the following secrets to your GitHub repository:
31+
32+
1. `VERCEL_TOKEN`: Your Vercel access token (generate at https://vercel.com/account/tokens)
33+
2. `VERCEL_ORG_ID`: Your organization ID from `.vercel/project.json`
34+
3. `VERCEL_PROJECT_ID`: Your project ID from `.vercel/project.json`
35+
36+
## Deployment Workflows
37+
38+
### Production Deployment
39+
40+
Production deployments are triggered automatically when you push a new tag:
41+
42+
```bash
43+
git tag v1.0.0
44+
git push origin v1.0.0
45+
```
46+
47+
### Hotfix Deployment
48+
49+
To deploy a hotfix directly to production:
50+
51+
1. Create and push to the `hotfix` branch:
52+
```bash
53+
git checkout -b hotfix
54+
# Make your changes
55+
git add .
56+
git commit -m "Fix critical issue"
57+
git push origin hotfix
58+
```
59+
60+
2. The hotfix will automatically deploy to production.
61+
62+
### Preview Deployments
63+
64+
Preview deployments are created automatically when pull requests are opened or updated, and the preview URL will be posted as a comment in the PR.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Hotfix Deployment
2+
3+
env:
4+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
5+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
6+
7+
on:
8+
push:
9+
branches:
10+
- hotfix
11+
12+
jobs:
13+
Deploy-Production:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: '18'
22+
23+
- name: Setup PNPM
24+
uses: pnpm/action-setup@v2
25+
with:
26+
version: '9.15.0'
27+
28+
- name: Set up .npmrc
29+
run: echo "registry=https://registry.npmjs.org" > .npmrc
30+
31+
- name: Install dependencies
32+
run: pnpm install --no-frozen-lockfile --ignore-scripts
33+
34+
- name: Install Vercel CLI
35+
run: pnpm add --global vercel@latest
36+
37+
- name: Pull Vercel Environment Information
38+
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
39+
40+
- name: Build Project Artifacts
41+
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
42+
43+
- name: Deploy Project Artifacts to Vercel
44+
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Preview Deployment
2+
3+
env:
4+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
5+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
6+
7+
on:
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
11+
# Add permissions section to allow commenting on issues/PRs
12+
permissions:
13+
pull-requests: write
14+
contents: read
15+
16+
jobs:
17+
Deploy-Preview:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: '18'
26+
27+
- name: Setup PNPM
28+
uses: pnpm/action-setup@v2
29+
with:
30+
version: '9.15.0'
31+
32+
- name: Set up .npmrc
33+
run: echo "registry=https://registry.npmjs.org" > .npmrc
34+
35+
- name: Install dependencies
36+
run: pnpm install --no-frozen-lockfile --ignore-scripts
37+
38+
- name: Install Vercel CLI
39+
run: pnpm add --global vercel@latest
40+
41+
- name: Pull Vercel Environment Information
42+
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
43+
44+
- name: Build Project Artifacts
45+
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
46+
47+
- name: Deploy Project Artifacts to Vercel
48+
id: deploy
49+
run: echo "url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_OUTPUT
50+
51+
- name: Add Preview Comment
52+
uses: actions/github-script@v6
53+
with:
54+
github-token: ${{ secrets.GITHUB_TOKEN }}
55+
script: |
56+
const url = process.env.DEPLOY_URL;
57+
github.rest.issues.createComment({
58+
issue_number: context.issue.number,
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
body: `✅ Preview deployment is ready!
62+
63+
🔗 Preview URL: ${url}`
64+
})
65+
env:
66+
DEPLOY_URL: ${{ steps.deploy.outputs.url }}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Production Tag Deployment
2+
3+
env:
4+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
5+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
6+
7+
on:
8+
push:
9+
# Pattern matched against refs/tags
10+
tags:
11+
- '*' # Push events to every tag not containing /
12+
13+
jobs:
14+
Deploy-Production:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '18'
23+
24+
- name: Setup PNPM
25+
uses: pnpm/action-setup@v2
26+
with:
27+
version: '9.15.0'
28+
29+
- name: Set up .npmrc
30+
run: echo "registry=https://registry.npmjs.org" > .npmrc
31+
32+
- name: Install dependencies
33+
run: pnpm install --no-frozen-lockfile --ignore-scripts
34+
35+
- name: Install Vercel CLI
36+
run: pnpm add --global vercel@latest
37+
38+
- name: Pull Vercel Environment Information
39+
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
40+
41+
- name: Build Project Artifacts
42+
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
43+
44+
- name: Deploy Project Artifacts to Vercel
45+
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

DEPLOY.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Deployment Guide
2+
3+
This project uses tag-based deployments with Vercel and GitHub Actions for CI/CD.
4+
5+
## Quick Start
6+
7+
### Initial Setup
8+
9+
Before your first deployment:
10+
11+
1. Install and login to Vercel CLI locally:
12+
```bash
13+
pnpm add --global vercel
14+
vercel login
15+
```
16+
17+
2. Link your project to get the organization and project IDs:
18+
```bash
19+
vercel link
20+
```
21+
22+
3. Add the following secrets to your GitHub repository:
23+
- `VERCEL_TOKEN`: Generate at https://vercel.com/account/tokens
24+
- `VERCEL_ORG_ID`: From `.vercel/project.json`
25+
- `VERCEL_PROJECT_ID`: From `.vercel/project.json`
26+
27+
### Deploying to Production
28+
29+
To deploy to production, create and push a new tag:
30+
31+
```bash
32+
git tag v1.0.0
33+
git push origin v1.0.0
34+
```
35+
36+
### Creating a Hotfix
37+
38+
For urgent fixes:
39+
40+
```bash
41+
git checkout -b hotfix
42+
# Make your changes
43+
git commit -am "Fix critical issue"
44+
git push origin hotfix
45+
```
46+
47+
### Preview Deployments
48+
49+
Pull requests automatically get preview deployments. The URL will be posted as a comment in the PR.
50+
51+
## How It Works
52+
53+
- The `vercel.json` file disables the default auto-deployments
54+
- GitHub Actions workflows handle deployments based on tags and branches
55+
- Production deployments are triggered by pushing tags
56+
- Hotfixes are deployed from the `hotfix` branch
57+
- Preview deployments are created for pull requests
58+
59+
For more details, see `.github/workflows/README.md`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "orbiton-app",
2+
"name": "@orbiton_labs/orbiton-app",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {

vercel.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"git": {
3+
"deploymentEnabled": false
4+
}
5+
}

0 commit comments

Comments
 (0)