-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
74 lines (65 loc) · 2.35 KB
/
Copy pathaction.yml
File metadata and controls
74 lines (65 loc) · 2.35 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
name: "Publish Documentation"
description: "Sync project docs to the docs repo via PR with auto-merge"
inputs:
project:
description: "Project name (used as subdirectory under en/ and zh/)"
required: true
docs-path:
description: "Path to docs directory in source repo"
required: false
default: "docs"
token:
description: "GitHub token with write access to docs repo"
required: true
runs:
using: "composite"
steps:
- name: Checkout docs repo
uses: actions/checkout@v4
with:
repository: clice-io/docs
token: ${{ inputs.token }}
path: __docs_repo
- name: Sync documentation
shell: bash
run: |
project="${{ inputs.project }}"
src="${{ inputs.docs-path }}"
rm -rf "__docs_repo/en/${project}"
rm -rf "__docs_repo/zh/${project}"
for tree in en zh; do
if [ -d "${src}/${tree}" ]; then
cp -rf "${src}/${tree}" "__docs_repo/${tree}/${project}"
fi
done
if [ -d "${src}/public" ]; then
cp -rf "${src}/public/." "__docs_repo/public/"
fi
# The snapshot corpus the feature pages' example cards read at build time.
rm -rf "__docs_repo/sources/${project}"
if [ -d "tests/snap" ]; then
mkdir -p "__docs_repo/sources/${project}/tests"
cp -rf "tests/snap" "__docs_repo/sources/${project}/tests/snap"
fi
- name: Create Pull Request
id: create-pr
uses: peter-evans/create-pull-request@v7
with:
path: __docs_repo
token: ${{ inputs.token }}
branch: sync/${{ inputs.project }}
title: "docs: sync ${{ inputs.project }}"
body: |
Automated documentation sync.
Source: [`${{ github.repository }}@${{ github.sha }}`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
commit-message: "docs: sync ${{ inputs.project }}"
author: "clice-bot <306533837+clice-bot@users.noreply.github.com>"
committer: "clice-bot <306533837+clice-bot@users.noreply.github.com>"
delete-branch: true
- name: Enable auto-merge
if: steps.create-pr.outputs.pull-request-number
shell: bash
run: gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash
env:
GH_TOKEN: ${{ inputs.token }}
GH_REPO: clice-io/docs