-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (56 loc) · 2.08 KB
/
deploy.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
name: Deploy MkDocs to Documentation Repo
on:
push:
branches:
- main
repository_dispatch:
types: [rebuild_docs]
env:
PYTHON_VERSION: '3.x'
MKDOCS_SITE_DIR: 'site'
DOCS_BRANCH: 'gh-pages'
DOCS_SUBDIR: 'ai-core-concepts'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install MkDocs and dependencies
run: |
pip install mkdocs mkdocs-material mkdocstrings
- name: Build the MkDocs site
run: mkdocs build
- name: Generate GitHub App token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: ${{ secrets.INSTALLATION_ID }}
- name: Clone the Documentation Repo
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git clone --branch ${{ env.DOCS_BRANCH }} https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/acceleratescience/resource-hub.git temp_docs
- name: Deploy to Documentation Repo
run: |
# Ensure the target directory exists
mkdir -p temp_docs/${{ env.DOCS_SUBDIR }}
# Sync the built site to the target directory
rsync -av --delete ${{ env.MKDOCS_SITE_DIR }}/ temp_docs/${{ env.DOCS_SUBDIR }}/
# Commit and push changes
cd temp_docs
git add .
git diff-index --quiet HEAD || (git stash && git pull --rebase origin ${{ env.DOCS_BRANCH }} && git stash pop)
git add .
git diff-index --quiet HEAD || git commit -m "Update ${{ env.DOCS_SUBDIR }} resource-hub"
git push origin ${{ env.DOCS_BRANCH }}
- name: Clean up
if: always()
run: |
rm -rf temp_docs