-
Notifications
You must be signed in to change notification settings - Fork 54
88 lines (73 loc) · 2.53 KB
/
docs_make.yml
File metadata and controls
88 lines (73 loc) · 2.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
name: Make Documentation
permissions:
contents: write
pull-requests: write
on:
workflow_dispatch:
schedule:
- cron: '10 2 * * 3'
# workflow_dispatch:
# push:
# branches:
# - main
jobs:
build_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install uv and dependencies
run: |
pip install uv
uv venv
uv pip install -e .[docs]
- name: Install pre-commit
run: uv pip install pre-commit
- name: Install modules from packages.json via uv, skipping "colrev"
run: |
jq -r '.[] | select(.module != "colrev") | .module' colrev/packages/packages.json | while read module; do
uv pip install $module
done
- name: Setup git
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
- name: Set branch name
run: |
echo "BRANCH_NAME=docs-update-$(date '+%Y-%m-%d_%H-%M-%S')" >> $GITHUB_ENV
echo ${{ env.BRANCH_NAME }}
- name: Switch to branch ${{ env.BRANCH_NAME }}
run: |
git checkout -b ${{ env.BRANCH_NAME }}
- name: Clean old documentation build
run: rm -rf docs/source/dev_docs/_autosummary/*
- name: Run docs update
run: uv run colrev env --update_package_list
- name: Build documentation with Sphinx
run: uv run sphinx-build -b html docs/source docs/build
- name: Run pre-commit hooks excluding black
continue-on-error: true
run: uv run pre-commit run --all-files
- name: Commit changes and create pull request
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add .
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update documentation"
git push --set-upstream origin ${{ env.BRANCH_NAME }}
# Fetch the main branch and check for differences
git fetch origin main:main
if git diff ${{ env.BRANCH_NAME }} main --quiet; then
echo "No effective changes to apply"
else
gh pr create --title "Update documentation" --body "This PR updates the documentation." --head ${{ env.BRANCH_NAME }} --base main
fi
fi