-
-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (105 loc) · 4.44 KB
/
Copy pathdeploy-web.yml
File metadata and controls
116 lines (105 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Deploy Web App
on:
workflow_call:
inputs:
ref:
description: "Git ref to build and deploy. Defaults to the caller's commit."
required: false
type: string
version:
description: "Application version to embed in the web build. Defaults to the version derived from the Git ref."
required: false
type: string
channel:
description: "Hosted app channel: latest deploys app.threadlines.dev, nightly deploys nightly.app.threadlines.dev."
required: false
type: string
default: latest
workflow_dispatch:
inputs:
ref:
description: "Git ref (tag or sha) to build and deploy. Use a release tag so the hosted app version matches the desktop build."
required: true
type: string
version:
description: "Application version to embed in the web build. Defaults to the version derived from the Git ref."
required: false
type: string
channel:
description: "Hosted app channel: latest deploys app.threadlines.dev, nightly deploys nightly.app.threadlines.dev."
required: true
type: choice
options:
- latest
- nightly
permissions:
contents: read
jobs:
deploy:
name: Deploy ${{ inputs.channel == 'nightly' && 'nightly.app.threadlines.dev' || 'app.threadlines.dev' }}
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: deploy-${{ inputs.channel == 'nightly' && 'nightly-' || '' }}app-threadlines-dev
cancel-in-progress: false
environment:
name: ${{ inputs.channel == 'nightly' && 'nightly.app.threadlines.dev' || 'app.threadlines.dev' }}
url: ${{ inputs.channel == 'nightly' && 'https://nightly.app.threadlines.dev' || 'https://app.threadlines.dev' }}
env:
VERCEL_CLI_VERSION: 54.14.5
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ inputs.channel == 'nightly' && secrets.VERCEL_PROJECT_ID_NIGHTLY || secrets.VERCEL_PROJECT_ID }}
APP_VERSION: ${{ inputs.version }}
VITE_HOSTED_APP_CHANNEL: ${{ inputs.channel == 'nightly' && 'nightly' || 'latest' }}
VITE_HOSTED_APP_URL: ${{ inputs.channel == 'nightly' && 'https://nightly.app.threadlines.dev' || 'https://app.threadlines.dev' }}
HOSTED_APP_URL: ${{ inputs.channel == 'nightly' && 'https://nightly.app.threadlines.dev' || 'https://app.threadlines.dev' }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref || github.sha }}
fetch-depth: 0
- name: Setup Vite+
uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1
with:
node-version-file: package.json
cache: true
version: "0.2.4"
run-install: false
- name: Install dependencies
run: vp install --frozen-lockfile
- name: Install Vercel CLI
run: npm install --global "vercel@${VERCEL_CLI_VERSION}"
- name: Verify Vercel deployment secrets
shell: bash
run: |
missing=()
for name in VERCEL_TOKEN VERCEL_ORG_ID VERCEL_PROJECT_ID; do
if [[ -z "${!name:-}" ]]; then
missing+=("$name")
fi
done
if (( ${#missing[@]} > 0 )); then
printf '::error::Missing required GitHub secret(s): %s\n' "${missing[*]}"
echo "Add VERCEL_TOKEN, VERCEL_ORG_ID, and VERCEL_PROJECT_ID to this repository's Actions secrets." >> "$GITHUB_STEP_SUMMARY"
exit 1
fi
- name: Pull Vercel production environment
run: vercel pull --yes --environment=production --token="$VERCEL_TOKEN"
- name: Build Vercel production artifact
run: vercel build --prod --token="$VERCEL_TOKEN"
- name: Deploy Vercel production artifact
shell: bash
run: |
vercel deploy --prebuilt --prod --yes --token="$VERCEL_TOKEN" | tee /tmp/vercel-deploy.log
deployment_url="$(grep -Eo 'https://[^ ]+' /tmp/vercel-deploy.log | tail -n 1)"
{
echo "### ${HOSTED_APP_URL#https://} deployment"
echo
echo "- Commit: $(git rev-parse HEAD)"
if [[ -n "$deployment_url" ]]; then
echo "- Deployment: $deployment_url"
fi
echo "- Production URL: $HOSTED_APP_URL"
} >> "$GITHUB_STEP_SUMMARY"