Skip to content

Commit 43d831d

Browse files
action compositions
1 parent d329dd8 commit 43d831d

File tree

4 files changed

+75
-34
lines changed

4 files changed

+75
-34
lines changed
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Deploy Vercel
2+
description: Deploy Vercel in two modes
3+
4+
inputs:
5+
vercel-token:
6+
description: 'Vercel token'
7+
required: true
8+
mode:
9+
description: 'Deployment mode'
10+
required: true
11+
default: 'production'
12+
13+
runs:
14+
using: 'composite'
15+
steps:
16+
- name: Install Vercel CLI
17+
run: npm install --global vercel@canary
18+
shell: bash
19+
20+
- name: PROD Vercel Deployment
21+
if: ${{ inputs.mode == 'production' }}
22+
run: |
23+
vercel pull --yes --environment=production --token=${{ inputs.vercel-token }}
24+
vercel build --prod --token=${{ inputs.vercel-token }}
25+
vercel deploy --prebuilt --prod --token=${{ inputs.vercel-token }}
26+
shell: bash
27+
28+
- name: PREVIEW Vercel Deployment
29+
if: ${{ inputs.mode == 'preview' }}
30+
run: |
31+
vercel pull --yes --environment=preview --token=${{ inputs.vercel-token }}
32+
vercel build --token=${{ inputs.vercel-token }}
33+
DEPLOY_OUTPUT="$(vercel deploy --token=${{ inputs.vercel-token }})"
34+
DEPLOY_URL=$(echo "$DEPLOY_OUTPUT" | grep http | tail -n 1)
35+
echo "DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_ENV
36+
shell: bash
37+
38+
- name: Comment with preview URL
39+
if: ${{ inputs.mode == 'preview' }}
40+
uses: actions/github-script@v7
41+
with:
42+
script: |
43+
const { DEPLOY_URL } = process.env;
44+
github.rest.issues.createComment({
45+
issue_number: context.issue.number,
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
body: `🔍 Preview URL: ${DEPLOY_URL}`
49+
});
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Setup
2+
description: Setup node project
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- name: Configure node
8+
uses: actions/setup-node@v4
9+
with:
10+
node-version-file: '.nvmrc'
11+
12+
- name: Install dependencies
13+
run: npm ci
14+
shell: bash

.github/workflows/deploy.yml

+6-17
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ jobs:
1313
uses: actions/checkout@v4
1414

1515
- name: Configure node
16-
uses: actions/setup-node@v4
17-
with:
18-
node-version-file: '.nvmrc'
19-
20-
- name: Install dependencies
21-
run: npm ci
16+
uses: ./.github/actions/setup-project
2217

2318
- name: Build the app
2419
run: npm run build
@@ -38,17 +33,11 @@ jobs:
3833
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
3934
timeout-minutes: 1
4035

41-
- name: Install Vercel CLI
42-
run: npm install --global vercel@canary
43-
44-
- name: Pull Vercel Environment Information
45-
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
46-
47-
- name: Build Project Artifacts
48-
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
49-
50-
- name: Deploy Project Artifacts to Vercel
51-
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
36+
- name: Deploy app to Vercel production env
37+
uses: ./.github/actions/deploy-vercel
38+
with:
39+
mode: 'production'
40+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
5241
env:
5342
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
5443
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

.github/workflows/pull_request.yml

+6-17
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ jobs:
1313
uses: actions/checkout@v4
1414

1515
- name: Configure node
16-
uses: actions/setup-node@v4
17-
with:
18-
node-version-file: '.nvmrc'
19-
20-
- name: Install dependencies
21-
run: npm ci
16+
uses: ./.github/actions/setup-project
2217

2318
- name: Lint code
2419
run: npm run lint
@@ -29,17 +24,11 @@ jobs:
2924
- name: Build the app
3025
run: npm run build
3126

32-
- name: Install Vercel CLI
33-
run: npm install --global vercel@canary
34-
35-
- name: Pull Vercel Environment Information
36-
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
37-
38-
- name: Build Project Artifacts
39-
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
40-
41-
- name: Deploy Project Artifacts to Vercel
42-
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
27+
- name: Deploy app to Vercel production env
28+
uses: ./.github/actions/deploy-vercel
29+
with:
30+
mode: 'preview'
31+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
4332
env:
4433
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
4534
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

0 commit comments

Comments
 (0)