-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (110 loc) · 3.95 KB
/
main.yml
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# This is a basic workflow to help you get started with Actions
name: Build and deploy [dev / prod]
# Controls when the action will run.
on:
workflow_dispatch:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches:
- master
- dev
env:
node_version: 20
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "install"
build-and-publish-production:
name: Build and publish production
# The type of runner that the job will run on
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
outputs:
build: ${{ steps.success.outputs.buildStatus }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: latest
- name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}
cache: 'pnpm'
- run: pnpm install --prod
- uses: actions/checkout@v4
- name: Install Vercel CLI
run: pnpm i --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
- id: success
if: success()
run: echo "buildStatus=success" >> $GITHUB_OUTPUT
build-and-publish-develop:
name: Build and publish develop
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'
outputs:
build: ${{ steps.success.outputs.buildStatus }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: latest
- name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}
cache: 'pnpm'
- run: pnpm install --prod
- uses: actions/checkout@v4
- name: Install Vercel CLI
run: pnpm i --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=development --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
- id: success
if: success()
run: echo "buildStatus=success" >> $GITHUB_OUTPUT
github-release:
needs: [build-and-publish-production, build-and-publish-develop]
if: always() && (needs.build-and-publish-production.outputs.build == 'success' || needs.build-and-publish-develop.outputs.build == 'success')
runs-on: ubuntu-latest
name: Generate Release Notes
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
with:
branches: |
[
'master',
{
name: 'dev',
prerelease: true
}
]
env:
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS }}
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUNNER_DEBUG: 1