forked from apache/doris-website
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (97 loc) · 4.19 KB
/
Copy pathmanual-build-zip.yml
File metadata and controls
106 lines (97 loc) · 4.19 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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
---
name: Manual Build and Package ZIP
on:
workflow_dispatch:
inputs:
locale:
description: 'Locale(s) to build (e.g. en, zh-CN, or "en zh-CN" for both)'
required: false
default: 'en zh-CN'
create_release:
description: 'Create a GitHub Release with the ZIP (true/false)'
required: false
default: 'false'
release_tag:
description: 'Release tag name (only used when create_release is true, e.g. build-20240101)'
required: false
default: ''
jobs:
build-and-zip:
name: Build and Package ZIP
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: |
npm install -g yarn
yarn cache clean
yarn
- name: Build
run: |
# Validate and sanitize locale input — only allow known safe locale identifiers
RAW_LOCALES="${{ github.event.inputs.locale }}"
LOCALE_ARGS=""
for loc in $RAW_LOCALES; do
if [[ "$loc" =~ ^[a-zA-Z]{2}(-[a-zA-Z]{2,4})?$ ]]; then
LOCALE_ARGS="$LOCALE_ARGS --locale $loc"
else
echo "::error::Invalid locale value: '$loc'. Expected format: 'en', 'zh-CN', etc."
exit 1
fi
done
export NODE_OPTIONS=--max-old-space-size=8192
PWA_SERVICE_WORKER_URL=https://doris.apache.org/sw.js yarn docusaurus build $LOCALE_ARGS
- name: Package build output as ZIP
run: |
BUILD_DATE=$(date +%Y%m%d-%H%M%S)
ZIP_NAME="doris-website-build-${BUILD_DATE}.zip"
echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV
cd build
zip -r "../${ZIP_NAME}" .
cd ..
echo "ZIP size: $(du -sh ${ZIP_NAME})"
- name: Upload ZIP as workflow artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ZIP_NAME }}
path: ${{ env.ZIP_NAME }}
retention-days: 7
- name: Create GitHub Release
if: ${{ github.event.inputs.create_release == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || format('build-{0}', github.run_number) }}
name: Website Build ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || format('#{0}', github.run_number) }}
body: |
Automated website build artifact.
- **Branch**: ${{ github.ref_name }}
- **Commit**: ${{ github.sha }}
- **Locale(s)**: ${{ github.event.inputs.locale }}
files: ${{ env.ZIP_NAME }}
token: ${{ github.token }}