-
Notifications
You must be signed in to change notification settings - Fork 11
169 lines (152 loc) · 6.05 KB
/
Copy pathdeploy.yml
File metadata and controls
169 lines (152 loc) · 6.05 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: ⬆️ Deploy
run-name: Deploy ${{ inputs.univer-docs-site && 'docs' || '' }} to ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }}
on:
workflow_dispatch:
inputs:
environment:
description: Environment to deploy
required: true
default: staging
type: environment
univer-docs-site:
description: Deploy univer-docs-site
type: boolean
default: true
image-tag:
description: Image tag (Optional, only used for existing images)
type: string
default: ''
runner-name:
description: The name of the runner
type: choice
default: github-runner
options:
- github-runner
- shenzhen
acr-region:
description: ACR registry
type: choice
default: shenzhen
options:
- cn-shenzhen
- us-east-1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-docker-image:
if: ${{ github.event_name == 'workflow_dispatch' && (inputs.univer-docs-site) && !inputs.image-tag }}
name: Build ${{ inputs.univer-docs-site && 'docs' || '' }} Docker Image
runs-on: ${{ inputs.runner-name == 'github-runner' && 'ubuntu-latest' || inputs.runner-name || 'ubuntu-latest' }}
timeout-minutes: 30
environment: ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }}
env:
NPM_REGISTRY: ''
CR: univer-acr-registry.cn-shenzhen.cr.aliyuncs.com
ACR_REGION: ${{ inputs.acr-region }}
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
submodules: true
persist-credentials: false
- uses: ./.github/actions/setup-docker
id: setup-docker
with:
runner-name: ${{ inputs.runner-name }}
environment: ${{ inputs.environment }}
- if: ${{ inputs.runner-name == 'shenzhen' }}
run: |
echo "NPM_REGISTRY=https://registry.npmmirror.com" >> $GITHUB_ENV
- name: Build and Push Docker Image
env:
EVENT_NAME: ${{ github.event_name }}
UNIVER_DOCS_SITE: ${{ inputs.univer-docs-site }}
BUILDER_NAME: ${{ steps.setup-docker.outputs.builder-name }}
PUSH_TAG_AS_LATEST: ${{ vars.PUSH_TAG_AS_LATEST }}
CR: ${{ env.CR }}
NPM_REGISTRY: ${{ env.NPM_REGISTRY }}
NEXT_POSTHOG_APIKEY: ${{ secrets.NEXT_POSTHOG_APIKEY }}
run: |
IMAGE_TAG=$(echo "$GITHUB_SHA" | cut -c 1-7)
if [ "$EVENT_NAME" == "schedule" ] || [ "$UNIVER_DOCS_SITE" == "true" ]; then
make push_image REPOSITORY=univer-docs-site \
PUSH_TAG="$IMAGE_TAG" \
BUILDER="$BUILDER_NAME" \
OSARCH=linux/amd64 \
PUSH_TAG_AS_LATEST="$PUSH_TAG_AS_LATEST" \
CR="$CR" NPM_REGISTRY="$NPM_REGISTRY" \
NEXT_POSTHOG_APIKEY="$NEXT_POSTHOG_APIKEY"
fi
deploy-site:
if: ${{ inputs.univer-docs-site }}
name: Deploy Site
needs: [build-docker-image]
runs-on: arc-runner-set
environment: ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }}
steps:
- name: Set IMAGE_TAG environment variable
env:
IMAGE_TAG_INPUT: ${{ inputs.image-tag }}
run: |
if [ -z "$IMAGE_TAG_INPUT" ]; then
echo "IMAGE_TAG=$(echo "$GITHUB_SHA" | cut -c 1-7)" >> "$GITHUB_ENV"
else
echo "IMAGE_TAG=$IMAGE_TAG_INPUT" >> "$GITHUB_ENV"
fi
- name: Set FEATURE environment variable
if: ${{ startsWith(github.event_name == 'schedule' && 'staging' || inputs.environment, 'feature') }}
run: echo "FEATURE=$(echo "${GITHUB_REF#refs/heads/feat/}")" >> "$GITHUB_ENV"
- uses: peter-evans/repository-dispatch@v2
name: Deploy Docs Site
if: ${{ github.event_name == 'schedule' || inputs.univer-docs-site }}
with:
token: ${{ secrets.GH_TOKEN }}
repository: dream-num/helm-chart-private
event-type: ${{ vars.DISPATCH_EVENT_TYPE }}
client-payload: >
{
"service": "univer-docs-site",
"tag": "${{ env.IMAGE_TAG }}",
"feature": "${{ env.FEATURE }}",
"registry":"${{ env.CR }}"
}
deploy-k8s:
name: DeployK8s
if: ${{ github.event_name == 'workflow_dispatch' && inputs.image-tag }}
runs-on: arc-runner-set
environment: ${{ github.event_name == 'schedule' && 'staging' || inputs.environment }}
steps:
- name: Set IMAGE_TAG environment variable
env:
IMAGE_TAG_INPUT: ${{ inputs.image-tag }}
run: |
if [ -z "$IMAGE_TAG_INPUT" ]; then
echo "IMAGE_TAG=$(echo "$GITHUB_SHA" | cut -c 1-7)" >> "$GITHUB_ENV"
else
echo "IMAGE_TAG=$IMAGE_TAG_INPUT" >> "$GITHUB_ENV"
fi
- name: Set FEATURE environment variable
if: ${{ startsWith(github.event_name == 'schedule' && 'staging' || inputs.environment, 'feature') }}
run: echo "FEATURE=$(echo "${GITHUB_REF#refs/heads/feat/}")" >> "$GITHUB_ENV"
- name: Set US ACR region
if: ${{ inputs.acr-region == 'us-east-1' || inputs.environment == 'prod' || inputs.environment == 'feature prod' }}
run: |
echo "CR=univer-acr-eastus-registry.us-east-1.cr.aliyuncs.com" >> "$GITHUB_ENV"
- uses: peter-evans/repository-dispatch@v2
name: Deploy Docs Site
if: ${{ github.event_name == 'schedule' || inputs.univer-docs-site }}
with:
token: ${{ secrets.GH_TOKEN }}
repository: dream-num/helm-chart-private
event-type: ${{ vars.DISPATCH_EVENT_TYPE }}
client-payload: >
{
"service": "univer-docs-site",
"tag": "${{ env.IMAGE_TAG }}",
"feature": "${{ env.FEATURE }}",
"registry":"${{ env.CR }}"
}