1
1
name : 🚀 Deploy to Vercel
2
-
3
2
on :
4
3
push :
5
4
branches :
6
5
- main
7
6
- demo
8
7
- ' **'
9
8
workflow_dispatch :
9
+ inputs :
10
+ branch :
11
+ description : " Which branch do you want to deploy from?"
12
+ required : false
13
+ default : " "
10
14
11
15
jobs :
12
16
build-and-deploy :
13
17
runs-on : ubuntu-latest
14
18
15
19
steps :
20
+ - name : Determine branch
21
+ id : determine_branch
22
+ run : |
23
+ # If this workflow is triggered manually AND a branch input is provided,
24
+ # use that. Otherwise, fall back to the automatically provided ref_name.
25
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.branch }}" != "" ]; then
26
+ echo "branchName=${{ inputs.branch }}" >> $GITHUB_OUTPUT
27
+ else
28
+ echo "branchName=${{ github.ref_name }}" >> $GITHUB_OUTPUT
29
+ fi
30
+
16
31
- name : Check out code
17
32
uses : actions/checkout@v3
33
+ with :
34
+ # Check out the branch from the previous step.
35
+ ref : ${{ steps.determine_branch.outputs.branchName }}
18
36
19
37
- name : Use Node.js
20
38
uses : actions/setup-node@v3
@@ -26,22 +44,24 @@ jobs:
26
44
27
45
# Build step for demo branch
28
46
- name : Build for Vercel (demo)
29
- if : ${{ github.ref_name == 'demo' }}
47
+ if : ${{ steps.determine_branch.outputs.branchName == 'demo' }}
30
48
env :
31
49
SUPABASE_ANON_KEY : ${{ secrets.DEPLOY_DEMO_SUPABASE_ANON_KEY }}
32
50
SUPABASE_URL : ${{ secrets.DEPLOY_DEMO_SUPABASE_URL }}
33
51
DL_SUPABASE_PROJECT : ${{ secrets.DEPLOY_DEMO_DL_SUPABASE_PROJECT }}
34
52
DL_DNSDUMP_URL : ${{ secrets.DEPLOY_PROD_DL_DNSDUMP_URL }}
35
53
DL_PREFERRED_SUBDOMAIN_PROVIDER : ${{ secrets.DEPLOY_PROD_DL_PREFERRED_SUBDOMAIN_PROVIDER }}
36
54
DL_SHODAN_URL : ${{ secrets.DEPLOY_PROD_DL_SHODAN_URL }}
55
+ DL_DEMO_USER : ${{ secrets.DEPLOY_DEMO_DL_DEMO_USER }}
56
+ DL_DEMO_PASS : ${{ secrets.DEPLOY_DEMO_DL_DEMO_PASS }}
37
57
NITRO_PRESET : ' vercel'
38
58
DL_ENV_TYPE : ' demo'
39
59
run : |
40
60
NODE_OPTIONS=--max-old-space-size=8192 npm run build:vercel
41
61
42
- # Build step for all other branches (prod/feature)
62
+ # Build step for main or other branches
43
63
- name : Build for Vercel (prod/feature)
44
- if : ${{ github.ref_name != 'demo' }}
64
+ if : ${{ steps.determine_branch.outputs.branchName != 'demo' }}
45
65
env :
46
66
DL_STRIPE_CANCEL_URL : ${{ secrets.DEPLOY_PROD_DL_STRIPE_CANCEL_URL }}
47
67
DL_STRIPE_CHECKOUT_URL : ${{ secrets.DEPLOY_PROD_DL_STRIPE_CHECKOUT_URL }}
@@ -60,18 +80,18 @@ jobs:
60
80
if : ${{ success() }}
61
81
run : |
62
82
npm install -g vercel
63
- if [ "${{ github.ref_name }}" = "main" ]; then
83
+ BRANCH="${{ steps.determine_branch.outputs.branchName }}"
84
+ if [ "$BRANCH" = "main" ]; then
64
85
echo "Deploying to production"
65
- vercel deploy --prebuilt --prod --confirm --token $VERCEL_TOKEN
66
- elif [ "${{ github.ref_name }} " = "demo" ]; then
86
+ npx vercel deploy --prebuilt --prod --yes --token $VERCEL_TOKEN
87
+ elif [ "$BRANCH " = "demo" ]; then
67
88
echo "Deploying to demo"
68
- vercel deploy --prebuilt --confirm --env NEXT_PUBLIC_SITE =demo --token $VERCEL_TOKEN
89
+ npx vercel deploy --prebuilt --yes --target =demo --token $VERCEL_TOKEN
69
90
else
70
91
echo "Deploying to feature environment"
71
- vercel deploy --prebuilt --confirm --env NEXT_PUBLIC_SITE=feature --token $VERCEL_TOKEN
92
+ npx vercel deploy --prebuilt --yes --target=staging --token $VERCEL_TOKEN
72
93
fi
73
94
env :
74
95
VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
75
96
VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
76
97
VERCEL_TOKEN : ${{ secrets.VERCEL_TOKEN }}
77
-
0 commit comments