-
Notifications
You must be signed in to change notification settings - Fork 24
90 lines (84 loc) · 2.86 KB
/
cd.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
name: build and push image
# 3个功能,
# 1. 默认更新 main 内容到 dev 文档
# 2. 更新指定分支版本文档
# 3. 可以设置指定版本为默认访问版本
on:
workflow_dispatch:
inputs:
branch:
description: 'Update Docs Version From Branch, e.g main for dev'
required: true
default: 'main'
is_set_default:
description: 'True To Set Default Version When Visited'
required: false
type: boolean
jobs:
build:
runs-on: ubuntu-latest
steps:
- id: checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.ACTIONTOKEN }}
ref: ${{ inputs.branch }} # 可以指定分支 checkout, 但不允许直接修改 gh-pages
- name: branch status
run: |
git status
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Intialiaze Python Env
run: |
git rev-parse --abbrev-ref HEAD
pip install -r requirements.txt
- name: Git Config
run: |
git fetch --all
git config --global user.email ${{ secrets.GITUSEREMAIL }}
git config --global user.name ${{ secrets.GITUSERNAME }}
- name: Mike dev Version Snapshot
if: ${{ inputs.branch == 'main' }}
run: |
mike deploy --push dev
- name: Mike ${{ inputs.branch }} Version Snapshot
if: ${{ inputs.branch != 'main' }}
run: |
mike deploy --push ${{ inputs.branch }}
- name: Mike Set Default Version
if: ${{ inputs.branch == 'main' && inputs.is_set_default }}
run: |
mike list
mike alias -u dev latest
mike list
mike set-default --push latest
- name: Mike Set Default Version
if: ${{ inputs.branch != 'main' && inputs.is_set_default }}
run: |
mike list
mike alias -u ${{ inputs.branch }} latest
mike list
mike set-default --push latest
- name: Login Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login Tencent Container Registry
uses: docker/login-action@v2
with:
registry: ccr.ccs.tencentyun.com
username: ${{ secrets.TCR_USERNAME }}
password: ${{ secrets.TCR_TOKEN }}
- name: Build && Push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
matrixorigin/matrixorigin.io.cn:${{ inputs.branch }}_${{ github.sha }}
matrixorigin/matrixorigin.io.cn:latest
ccr.ccs.tencentyun.com/mo-fronted/matrixorigin.io.cn:${{ inputs.branch }}_${{ github.sha }}
ccr.ccs.tencentyun.com/mo-fronted/matrixorigin.io.cn:latest