-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (104 loc) · 3.92 KB
/
Copy pathupload.yml
File metadata and controls
114 lines (104 loc) · 3.92 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
# Publish the docs for AI Q&A: sync them into Meilisearch, and publish
# flashduty-docs.tar.gz (the same docs as Markdown files, plus the OpenAPI
# specs and glossary) for tools that grep and read the docs directly.
#
# The Meilisearch sync covers the whole doc set: all docs are upserted and
# index documents whose source file is gone are deleted.
#
# Uses GitHub Environments for dev/prod separation. Create two environments in
# Settings > Environments: "development" and "production".
#
# Per-environment secrets (all required, keep as secrets to hide Meilisearch endpoint):
# MEILI_ENDPOINT - Meilisearch instance URL
# MEILI_API_KEY - API key with documents read/write permission
# MEILI_INDEX - Target index name
# Branch mapping for the Meilisearch sync: main -> production,
# test -> development.
#
# The tarball is published from main only, to the Flashduty static
# distribution: https://static.flashcat.cloud/flashduty-docs/flashduty-docs.tar.gz
# (OSS bucket flashduty-public). Every deployment reads that one copy.
# Repository secrets for it: STATIC_ACCESS_KEY, STATIC_SECRET_KEY (an AK allowed
# to put objects under flashduty-public/flashduty-docs/).
name: Publish docs for AI search
on:
push:
branches: [main, test]
paths:
- 'zh/**'
- 'en/**'
- 'docs.json'
- 'api-reference/**'
- 'glossary.md'
- 'integration-docs/scripts/*docs-bundle*'
- 'integration-docs/scripts/oss-cdn.mjs'
- 'integration-docs/scripts/cdn-url.mjs'
- 'integration-docs/package.json'
- '.github/workflows/upload.yml'
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
default: 'production'
type: choice
options:
- production
- development
jobs:
upload:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production' || 'development') }}
# One sync per index at a time: an older run listing the index while a
# newer one uploads would delete the newer run's added docs.
concurrency:
group: meilisearch-upload-${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'production' || 'development') }}
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq
jq --version
- name: Upload to Meilisearch
env:
MEILI_ENDPOINT: ${{ secrets.MEILI_ENDPOINT }}
MEILI_API_KEY: ${{ secrets.MEILI_API_KEY }}
MEILI_INDEX: ${{ secrets.MEILI_INDEX }}
run: |
chmod +x ./scripts/upload.sh
bash ./scripts/upload.sh
bundle:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
# Every run uploads the whole tarball, so a newer run supersedes an older
# one; cancelling the older keeps it from finishing last with stale docs.
concurrency:
group: docs-bundle
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
working-directory: integration-docs
run: npm install
- name: Test docs bundle scripts
working-directory: integration-docs
run: npm run test:docs-bundle
- name: Build and upload docs bundle
working-directory: integration-docs
env:
CDN_ACCESS_KEY: ${{ secrets.STATIC_ACCESS_KEY }}
CDN_SECRET_KEY: ${{ secrets.STATIC_SECRET_KEY }}
CDN_BUCKET: 'flashduty-public'
CDN_REGION: 'oss-cn-beijing'
CDN_ENDPOINT: 'oss-cn-beijing.aliyuncs.com'
CDN_URL: 'https://static.flashcat.cloud'
CDN_DIR: '/flashduty-docs'
run: npm run upload:docs-bundle