-
Notifications
You must be signed in to change notification settings - Fork 245
81 lines (78 loc) · 2.45 KB
/
gh-pages.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
75
76
77
78
79
80
81
# Workflow that publishes to the gh-pacges branch
name: GitHub Pages
on:
merge_group: {}
pull_request:
branches: [main]
push:
branches: [main]
paths: [gh-pages/**]
workflow_dispatch:
jobs:
build:
name: build
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
cache: 'pip'
cache-dependency-path: 'gh-pages/requirements-dev.txt'
python-version: '3.8'
- name: Install Dependencies
run: |-
python3 -m venv ${{ runner.temp }}/venv
source ${{ runner.temp }}/venv/bin/activate
python3 -m pip install -r requirements-dev.txt
working-directory: gh-pages
- name: Build DocSite
run: |-
mkdir -p ${{ runner.temp }}/site
source ${{ runner.temp }}/venv/bin/activate
mkdocs build \
--strict \
--site-dir ${{ runner.temp }}/site
working-directory: gh-pages
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: doc-site
path: ${{ runner.temp }}/site/
publish:
name: Publish
needs: build
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
with:
ref: gh-pages
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: doc-site
path: ${{ runner.temp }}/site
- name: Configure Git
run: |-
git config user.name "AWS CDK Automation"
git config user.email "aws-cdk+automation@amazon.com"
- name: Prepare Commit
run: |-
rsync --archive --checksum --delete --inplace --recursive --verbose \
--exclude=.git --exclude=.nojekyll --exclude=dev \
${{ runner.temp }}/site/ ./
git add .
git diff --cached --exit-code >/dev/null || (
git commit -am 'docs: publish from ${{ github.sha }}'
)
- name: Push
run: |-
git push origin gh-pages:gh-pages