|
1 | | -name: Publish documentation |
| 1 | +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/deploy-cobra-mkdocs-versioned-poetry.md |
| 2 | +name: Deploy Website |
2 | 3 |
|
3 | 4 | on: |
4 | 5 | push: |
5 | 6 | branches: |
| 7 | + # Branch to base "dev" website on. Set in siteversion.py also. |
6 | 8 | - main |
7 | 9 | # Release branches have names like 0.8.x, 0.9.x, ... |
8 | 10 | - "[0-9]+.[0-9]+.x" |
9 | 11 | paths: |
10 | 12 | - "docs/**" |
| 13 | + - ".github/workflows/deploy-cobra-mkdocs-versioned-poetry.ya?ml" |
| 14 | + - "go.mod" |
| 15 | + - "go.sum" |
| 16 | + - "Taskfile.ya?ml" |
| 17 | + - "**.go" |
11 | 18 | - "docsgen/**" |
12 | | - - "cli/**" |
13 | | - - ".github/workflows/publish-docs.yml" |
| 19 | + - "mkdocs.ya?ml" |
| 20 | + - "poetry.lock" |
| 21 | + - "pyproject.toml" |
14 | 22 | # Run on branch or tag creation (will be filtered by the publish-determination job). |
15 | 23 | create: |
16 | 24 |
|
@@ -38,46 +46,45 @@ jobs: |
38 | 46 | if: needs.publish-determination.outputs.result == 'true' |
39 | 47 |
|
40 | 48 | steps: |
41 | | - - name: Checkout local repository |
| 49 | + - name: Checkout repository |
42 | 50 | uses: actions/checkout@v2 |
43 | 51 |
|
44 | | - - name: Install Taskfile |
45 | | - uses: arduino/setup-task@v1 |
46 | | - with: |
47 | | - repo-token: ${{ secrets.GITHUB_TOKEN }} |
48 | | - version: 3.x |
49 | | - |
50 | | - - name: Install Go |
51 | | - uses: actions/setup-go@v2 |
52 | | - with: |
53 | | - go-version: "1.14" |
54 | | - |
55 | 52 | - name: Install Python |
56 | 53 | uses: actions/setup-python@v2 |
57 | 54 | with: |
58 | | - python-version: "3.8" |
59 | | - |
60 | | - - name: Cache dependencies |
61 | | - uses: actions/cache@v2 |
62 | | - with: |
63 | | - path: ~/.cache/pip |
64 | | - key: ${{ runner.os }}-pip-${{ hashFiles('./pyproject.toml') }} |
65 | | - restore-keys: | |
66 | | - ${{ runner.os }}-pip- |
| 55 | + python-version: "3.9" |
67 | 56 |
|
68 | 57 | - name: Install Poetry |
69 | 58 | run: | |
70 | 59 | python -m pip install --upgrade pip |
71 | 60 | python -m pip install poetry |
72 | 61 |
|
| 62 | + - name: Install Task |
| 63 | + uses: arduino/setup-task@v1 |
| 64 | + with: |
| 65 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + version: 3.x |
| 67 | + |
| 68 | + - name: Create all generated documentation content |
| 69 | + run: task docs:generate |
| 70 | + |
73 | 71 | - name: Install Python dependencies |
74 | 72 | run: poetry install --no-root |
75 | 73 |
|
| 74 | + - name: Determine versioning parameters |
| 75 | + id: determine-versioning |
| 76 | + run: echo "::set-output name=data::$(poetry run python docs/siteversion/siteversion.py)" |
| 77 | + |
76 | 78 | - name: Publish documentation |
77 | | - # Determine docs version for the commit pushed and publish accordingly using Mike. |
78 | | - # Publishing implies creating a git commit on the gh-pages branch, we let @ArduinoBot own these commits. |
| 79 | + if: fromJson(steps.determine-versioning.outputs.data).version != null |
79 | 80 | run: | |
| 81 | + # Publishing implies creating a git commit on the gh-pages branch, we let @ArduinoBot own these commits. |
80 | 82 | git config --global user.email "bot@arduino.cc" |
81 | 83 | git config --global user.name "ArduinoBot" |
82 | 84 | git fetch --no-tags --prune --depth=1 origin +refs/heads/gh-pages:refs/remotes/origin/gh-pages |
83 | | - poetry run python docs/build.py |
| 85 | + poetry run mike deploy \ |
| 86 | + --update-aliases \ |
| 87 | + --push \ |
| 88 | + --remote origin \ |
| 89 | + ${{ fromJson(steps.determine-versioning.outputs.data).version }} \ |
| 90 | + ${{ fromJson(steps.determine-versioning.outputs.data).alias }} |
0 commit comments