|
| 1 | +name: Publish documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + # Release branches have names like 0.8.x, 0.9.x, ... |
| 8 | + - "[0-9]+.[0-9]+.x" |
| 9 | + paths: |
| 10 | + - "docs/**" |
| 11 | + - "docsgen/**" |
| 12 | + - "cli/**" |
| 13 | + - ".github/workflows/publish-docs.yml" |
| 14 | + # Run on branch or tag creation (will be filtered by the publish-determination job). |
| 15 | + create: |
| 16 | + |
| 17 | +jobs: |
| 18 | + publish-determination: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + result: ${{ steps.determination.outputs.result }} |
| 22 | + steps: |
| 23 | + - name: Determine if documentation should be published on this workflow run |
| 24 | + id: determination |
| 25 | + run: | |
| 26 | + RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" |
| 27 | + if [[ "${{ github.event_name }}" == "push" || ( "${{ github.event_name }}" == "create" && "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX ) ]]; then |
| 28 | + RESULT="true" |
| 29 | + else |
| 30 | + RESULT="false" |
| 31 | + fi |
| 32 | +
|
| 33 | + echo "::set-output name=result::$RESULT" |
| 34 | +
|
| 35 | + publish: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: publish-determination |
| 38 | + if: needs.publish-determination.outputs.result == 'true' |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout local repository |
| 42 | + uses: actions/checkout@v2 |
| 43 | + |
| 44 | + - name: Install Taskfile |
| 45 | + uses: arduino/actions/setup-taskfile@master |
| 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 | + - name: Install Python |
| 56 | + uses: actions/setup-python@v2 |
| 57 | + 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- |
| 67 | +
|
| 68 | + - name: Install Poetry |
| 69 | + run: | |
| 70 | + python -m pip install --upgrade pip |
| 71 | + python -m pip install poetry |
| 72 | +
|
| 73 | + - name: Install Python dependencies |
| 74 | + run: poetry install --no-root |
| 75 | + |
| 76 | + - 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 | + run: | |
| 80 | + git config --global user.email "bot@arduino.cc" |
| 81 | + git config --global user.name "ArduinoBot" |
| 82 | + git fetch --no-tags --prune --depth=1 origin +refs/heads/gh-pages:refs/remotes/origin/gh-pages |
| 83 | + poetry run python docs/build.py |
0 commit comments