forked from ClickHouse/clickhouse-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.35 KB
/
table_of_contents.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
# This GitHub Action is used for triggering updates of
# the toc.json files present in any directory that
# needs an automatically generated table of contents.
name: Generate Table of Contents files
env:
# Force the stdout and stderr streams to be unbuffered
PYTHONUNBUFFERED: 1
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
generate_toc_formats:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Check out repository
uses: actions/checkout@v3
# Step 2 - Setup Python
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
# Step 3: Install Python dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r 'scripts/table-of-contents-generator/requirements.txt'
# Step 4 - Pull main repo docs, run script to generate TOCs:
- name: Generate TOCs
run: |
yarn prep-from-master
python -u ./scripts/table-of-contents-generator/toc_gen.py --dir="docs/en/interfaces/formats" --single-toc --out="table-of-contents-files" --ignore "_snippets"
# Step 5 - Fail the workflow if script returns exit code 1
- name: Check exit code
run: |
if [[ "${{ steps.toc_gen.outcome }}" == "failure" ]]; then
echo "Ran into trouble generating a table of contents. See the logs for details."
exit 1
fi
# Step 6 - Check if anything was actually updated
- name: Check for Changes
id: check_changes
run: |
git status -u
if [[ -n "$(git diff --exit-code)" ]]; then
echo "Changes detected."
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "No changes detected."
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
# Step 7 - Commit and Push generated Table Of Contents files
- uses: stefanzweifel/git-auto-commit-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit_message: "Autogenerate table of contents files from GitHub action - $(date '+%Y-%m-%d %H:%M:%S')"
file_pattern: 'table-of-contents-files/*'
branch: generate_table_of_contents
create_branch: true