Deploy Website #1092
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/deploy-cobra-mkdocs-versioned-poetry.md | |
name: Deploy Website | |
env: | |
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax | |
GO_VERSION: "1.22" | |
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python | |
PYTHON_VERSION: "3.9" | |
on: | |
push: | |
branches: | |
# Branch to base "dev" website on. Set in siteversion.py also. | |
- master | |
# Release branches have names like 0.8.x, 0.9.x, ... | |
- "[0-9]+.[0-9]+.x" | |
paths: | |
- "docs/**" | |
- ".github/workflows/deploy-cobra-mkdocs-versioned-poetry.ya?ml" | |
- "go.mod" | |
- "go.sum" | |
- "Taskfile.ya?ml" | |
- "**.go" | |
- "internal/docsgen/**" | |
- "rpc/**" | |
- "mkdocs.ya?ml" | |
- "poetry.lock" | |
- "pyproject.toml" | |
# Run on branch or tag creation (will be filtered by the publish-determination job). | |
create: | |
jobs: | |
publish-determination: | |
runs-on: ubuntu-latest | |
outputs: | |
result: ${{ steps.determination.outputs.result }} | |
steps: | |
- name: Determine if documentation should be published on this workflow run | |
id: determination | |
run: | | |
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" | |
if [[ "${{ github.event_name }}" == "push" || ( "${{ github.event_name }}" == "create" && "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX ) ]]; then | |
RESULT="true" | |
else | |
RESULT="false" | |
fi | |
echo "result=$RESULT" >> $GITHUB_OUTPUT | |
publish: | |
runs-on: ubuntu-latest | |
needs: publish-determination | |
if: needs.publish-determination.outputs.result == 'true' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Install Go dependencies | |
run: go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@v1.4.1 | |
- name: Install protoc compiler | |
uses: arduino/setup-protoc@v3 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install Poetry | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install poetry | |
- name: Install Task | |
uses: arduino/setup-task@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
version: 3.x | |
- name: Create all generated documentation content | |
run: task docs:generate | |
- name: Install Python dependencies | |
run: poetry install --no-root | |
- name: Determine versioning parameters | |
id: determine-versioning | |
run: echo "data=$(poetry run python docs/siteversion/siteversion.py)" >> $GITHUB_OUTPUT | |
- name: Publish documentation | |
if: fromJson(steps.determine-versioning.outputs.data).version != null | |
run: | | |
# Publishing implies creating a git commit on the gh-pages branch, we let @ArduinoBot own these commits. | |
git config --global user.email "bot@arduino.cc" | |
git config --global user.name "ArduinoBot" | |
git fetch --no-tags --prune --depth=1 origin +refs/heads/gh-pages:refs/remotes/origin/gh-pages | |
poetry run mike deploy \ | |
--update-aliases \ | |
--push \ | |
--remote origin \ | |
${{ fromJson(steps.determine-versioning.outputs.data).version }} \ | |
${{ fromJson(steps.determine-versioning.outputs.data).alias }} |