-
Notifications
You must be signed in to change notification settings - Fork 189
136 lines (120 loc) · 4.53 KB
/
docs-deploy-verify.yaml
File metadata and controls
136 lines (120 loc) · 4.53 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
name: Docs Deploy Verify
on:
workflow_dispatch:
inputs:
line:
description: 'Docs line (v1 or v2)'
required: true
default: 'v2'
type: choice
options:
- v1
- v2
source_ref:
description: 'Git ref to build (branch or tag)'
required: true
default: 'refs/heads/updata-2602'
type: string
verify_id:
description: 'Verify directory suffix (defaults to run id)'
required: false
type: string
concurrency:
group: docs-deploy-verify-${{ github.ref }}-${{ inputs.line }}
cancel-in-progress: false
permissions:
contents: read
jobs:
build-and-upload-verify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.source_ref }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: |
npm i -g pnpm
pnpm install
- name: Resolve docs env
id: docs_env
run: |
if [[ "${{ inputs.line }}" == "v2" ]]; then
echo "PUBLIC_ORIGIN=https://v2.element-plus-x.com" >> $GITHUB_OUTPUT
echo "VERSION_LABEL=v2.x (Verify)" >> $GITHUB_OUTPUT
else
echo "PUBLIC_ORIGIN=https://v1.element-plus-x.com" >> $GITHUB_OUTPUT
echo "VERSION_LABEL=v1.x (Verify)" >> $GITHUB_OUTPUT
fi
- name: Build docs
env:
DOCS_LINE: ${{ inputs.line }}
DOCS_PUBLIC_ORIGIN: ${{ steps.docs_env.outputs.PUBLIC_ORIGIN }}
DOCS_VERSION_LABEL: ${{ steps.docs_env.outputs.VERSION_LABEL }}
DOCS_V1_ORIGIN: https://v1.element-plus-x.com
DOCS_V2_ORIGIN: https://v2.element-plus-x.com
DOCS_ROOT_ORIGIN: https://element-plus-x.com
DOCS_USE_SOURCE: 'true'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p apps/internal/metadata/dist
if [[ ! -f apps/internal/metadata/dist/component-contributors.json ]]; then
echo '{}' > apps/internal/metadata/dist/component-contributors.json
fi
pnpm run gen:changelog
pnpm -C apps/docs build
- name: Resolve verify path
id: verify_path
env:
DOCS_DEPLOY_BASE_DIR: ${{ secrets.DOCS_DEPLOY_BASE_DIR }}
run: |
VERIFY_ID="${{ inputs.verify_id }}"
if [[ -z "$VERIFY_ID" ]]; then
VERIFY_ID="${{ github.run_id }}"
fi
REMOTE_DIR="${DOCS_DEPLOY_BASE_DIR}/verify/${{ inputs.line }}/$VERIFY_ID"
echo "VERIFY_ID=$VERIFY_ID" >> $GITHUB_OUTPUT
echo "REMOTE_DIR=$REMOTE_DIR" >> $GITHUB_OUTPUT
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DOCS_DEPLOY_SSH_KEY }}
- name: Add deploy host to known_hosts
env:
DOCS_DEPLOY_HOST: ${{ secrets.DOCS_DEPLOY_HOST }}
DOCS_DEPLOY_PORT: ${{ secrets.DOCS_DEPLOY_PORT }}
run: |
mkdir -p ~/.ssh
PORT="${DOCS_DEPLOY_PORT:-22}"
ssh-keyscan -p "$PORT" -H "$DOCS_DEPLOY_HOST" >> ~/.ssh/known_hosts
- name: Upload verify build
env:
DOCS_DEPLOY_HOST: ${{ secrets.DOCS_DEPLOY_HOST }}
DOCS_DEPLOY_PORT: ${{ secrets.DOCS_DEPLOY_PORT }}
DOCS_DEPLOY_USER: ${{ secrets.DOCS_DEPLOY_USER }}
run: |
PORT="${DOCS_DEPLOY_PORT:-22}"
REMOTE_DIR="${{ steps.verify_path.outputs.REMOTE_DIR }}"
ssh -p "$PORT" "$DOCS_DEPLOY_USER@$DOCS_DEPLOY_HOST" "mkdir -p '$REMOTE_DIR'"
rsync -az --delete -e "ssh -p $PORT" apps/docs/.vitepress/dist/ "$DOCS_DEPLOY_USER@$DOCS_DEPLOY_HOST:$REMOTE_DIR/"
- name: Verify remote artifacts
env:
DOCS_DEPLOY_HOST: ${{ secrets.DOCS_DEPLOY_HOST }}
DOCS_DEPLOY_PORT: ${{ secrets.DOCS_DEPLOY_PORT }}
DOCS_DEPLOY_USER: ${{ secrets.DOCS_DEPLOY_USER }}
run: |
PORT="${DOCS_DEPLOY_PORT:-22}"
REMOTE_DIR="${{ steps.verify_path.outputs.REMOTE_DIR }}"
ssh -p "$PORT" "$DOCS_DEPLOY_USER@$DOCS_DEPLOY_HOST" "\
test -d '$REMOTE_DIR' && \
test -f '$REMOTE_DIR/index.html' && \
(test -d '$REMOTE_DIR/assets' || test -d '$REMOTE_DIR/.vitepress')"
- name: Print verify target
run: |
echo "Docs verify upload completed."
echo "Remote path: ${{ steps.verify_path.outputs.REMOTE_DIR }}"