-
Notifications
You must be signed in to change notification settings - Fork 19
160 lines (137 loc) · 5.16 KB
/
build.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
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build CI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
ref:
description: "Why trigger?"
required: true
type: string
env:
IMAGE: "docs"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 12.x
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/[email protected]
with:
version: 6
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: docs-${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
docs-${{ runner.os }}-pnpm-store-
- name: Node build
shell: bash
run: |
pnpm install
node downloadCSV.js
pnpm run build
node copy-file.js
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to ALIYUN Docker Registry
uses: docker/login-action@v2
with:
registry: "${{ secrets.REGISTRY_ALIYUN_ADDR }}"
username: "${{ secrets.REGISTRY_ALIYUN_USER }}"
password: "${{ secrets.REGISTRY_PASS }}"
# - name: debug
# shell: bash
# run: |
# more $GITHUB_EVENT_PATH
- name: set env
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' }}
run: |
echo "IMAGE_TAG_PREFIX=${{ github.event.pull_request.head.ref }}"|sed 's|main|latest|' >> $GITHUB_ENV
- name: set env
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
run: |
echo "IMAGE_TAG_PREFIX=${{ github.ref_name }}"|sed 's|main|latest|' >> $GITHUB_ENV
- name: Build and push docs image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: true
tags: |
"${{ secrets.REGISTRY_ALIYUN_ADDR }}/deepservice/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ github.run_id }}-${{ github.run_attempt }}"
"${{ secrets.REGISTRY_ALIYUN_ADDR }}/deepservice/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}"
- name: template
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
echo "TEMPLATE=red" >> $GITHUB_ENV
- name: template
if: ${{ github.event_name == 'push' }}
shell: bash
run: |
echo "TEMPLATE=green" >> $GITHUB_ENV
- name: info
shell: bash
run: |
curl -X POST -H "Content-Type: application/json" -d \
'{"msg_type":"interactive","card":
{
"config": {
"wide_screen_mode": true
},
"elements": [
{
"tag": "div",
"text": {
"content": "docs分支: ${{ github.ref_name }}\n镜像tag:${{ github.run_id }}-${{ github.run_attempt }}\nmain分支自动更新到测试环境\n更新命令:\nkubectl set image -n deepservice-test deployment deepservice-docs deepservice-docs=${{ secrets.REGISTRY_ALIYUN_ADDR }}/deepservice/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ github.run_id }}-${{ github.run_attempt }}",
"tag": "lark_md"
}
}
],
"header": {
"template": "${{ env.TEMPLATE }}",
"title": {
"content": "👻DeepFlow (Community)-docs ${{ github.event_name }} 事件",
"tag": "plain_text"
}
}
}
}' \
${{ secrets.FEISHU_ROBOT }}
- name: set kubeconfig
shell: bash
run: |
mkdir -p ~/.kube
echo "${{ secrets.DEEPFLOWIOKUBECONFIG}}" >> ~/.kube/config
- name: update
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true }}
shell: bash
run: |
kubectl set image -n deepservice-test deployment deepservice-docs deepservice-docs=${{ secrets.REGISTRY_ALIYUN_ADDR }}/deepservice/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: update
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
shell: bash
run: |
kubectl set image -n deepservice-test deployment deepservice-docs deepservice-docs=${{ secrets.REGISTRY_ALIYUN_ADDR }}/deepservice/${{ env.IMAGE }}:${{ env.IMAGE_TAG_PREFIX }}-${{ github.run_id }}-${{ github.run_attempt }}