-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (108 loc) · 4.06 KB
/
Copy pathpush.yml
File metadata and controls
120 lines (108 loc) · 4.06 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
name: Deploy Workspace
on:
workflow_dispatch:
inputs:
release_tag:
description: Optional existing stable Workspace release tag in vX.Y.Z form
type: string
required: false
environment:
description: 'Environment to run deploy'
type: environment
required: true
default: staging
runner-name:
description: Runner
type: choice
default: 'github-runner'
options:
- 'github-runner'
- 'shenzhen'
acr-region:
description: ACR registry
type: choice
default: 'cn-shenzhen'
options:
- 'cn-shenzhen'
- 'us-east-1'
permissions:
contents: read
jobs:
build-docker-image:
name: BuildDockerImage
runs-on: ${{ inputs.runner-name == 'github-runner' && 'ubuntu-latest' || inputs.runner-name }}
environment: ${{ inputs.environment }}
outputs:
image_tag: ${{ steps.release.outputs.image_tag }}
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}
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:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ inputs.release_tag == '' && github.sha || format('refs/tags/{0}', inputs.release_tag) }}
- name: Resolve deployment source
id: release
shell: bash
env:
BASE_BRANCH: ${{ github.event.repository.default_branch }}
DISPATCH_SHA: ${{ github.sha }}
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
set -euo pipefail
if [[ -n "$RELEASE_TAG" ]]; then
if [[ ! "$RELEASE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
echo "release_tag must use stable vX.Y.Z form" >&2
exit 1
fi
if [[ "$(git rev-parse "refs/tags/$RELEASE_TAG^{commit}")" != "$(git rev-parse HEAD)" ]]; then
echo "Checkout does not match release tag $RELEASE_TAG" >&2
exit 1
fi
if ! git merge-base --is-ancestor HEAD "refs/remotes/origin/$BASE_BRANCH"; then
echo "Release tag commit must be contained in origin/$BASE_BRANCH" >&2
exit 1
fi
IMAGE_TAG="$RELEASE_TAG"
else
IMAGE_TAG="sha-$DISPATCH_SHA"
fi
echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
- uses: ./.github/actions/setup
id: setup
with:
runner-name: ${{ inputs.runner-name }}
environment: ${{ inputs.environment }}
- name: Build and Push Image
env:
IMAGE_TAG: ${{ steps.release.outputs.image_tag }}
UNIVER_WORKSPACE_BROWSER_LICENSE: ${{ secrets.UNIVER_WORKSPACE_BROWSER_LICENSE }}
run: |
make push_image "IMAGE_TAG=$IMAGE_TAG" "CR=$CR"
deploy-k8s:
name: DeployK8s
runs-on: arc-runner-set
needs: build-docker-image
environment: ${{ inputs.environment }}
env:
CR: univer-acr-registry.cn-shenzhen.cr.aliyuncs.com
IMAGE_TAG: ${{ needs.build-docker-image.outputs.image_tag }}
steps:
- name: Set FEATURE environment variable
if: ${{ startsWith(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
with:
token: ${{ secrets.GH_TOKEN }}
repository: dream-num/helm-chart-private
event-type: ${{ vars.DISPATCH_EVENT_TYPE }}
client-payload: '{"service":"colla-workspace","tag":"${{ env.IMAGE_TAG }}","feature":"${{ env.FEATURE }}","registry":"${{ env.CR }}"}'