|
| 1 | +# |
| 2 | +# Copyright 2025 Paul Guyot <[email protected]> |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later |
| 5 | +# |
| 6 | +name: Build Tutorials |
| 7 | + |
| 8 | +on: |
| 9 | + # Triggers the workflow on push request and tag events on main branch |
| 10 | + pull_request: |
| 11 | + tags: |
| 12 | + - '**' |
| 13 | + branches: |
| 14 | + - 'main' |
| 15 | + - 'release-**' |
| 16 | + paths: |
| 17 | + - '.github/workflows/**' |
| 18 | + - 'CMakeLists.txt' |
| 19 | + - 'CMakeModules/**' |
| 20 | + - 'tutorials/**' |
| 21 | + push: |
| 22 | + repositories: |
| 23 | + - '!atomvm_examples/AtomVM' |
| 24 | + paths: |
| 25 | + - '.github/workflows/**' |
| 26 | + - 'CMakeLists.txt' |
| 27 | + - 'CMakeModules/**' |
| 28 | + - 'tutorials/**' |
| 29 | + |
| 30 | + # Allows you to run this workflow manually from the Actions tab |
| 31 | + workflow_dispatch: |
| 32 | + |
| 33 | +concurrency: |
| 34 | + group: ${{ github.workflow }}-${{ github.ref != 'refs/heads/main' && github.ref || github.run_id }} |
| 35 | + cancel-in-progress: true |
| 36 | + |
| 37 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 38 | +jobs: |
| 39 | + # This workflow contains a single job called "build" |
| 40 | + build: |
| 41 | + |
| 42 | + # The type of runner that the job will run on |
| 43 | + runs-on: ubuntu-24.04 |
| 44 | + container: erlang:28.1 |
| 45 | + |
| 46 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 47 | + steps: |
| 48 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 49 | + - name: Install Deps |
| 50 | + run: | |
| 51 | + apt update -y |
| 52 | + DEBIAN_FRONTEND=noninteractive apt install -y git cmake doxygen graphviz python3-pip python3-virtualenv python3-setuptools python3-stemmer wget |
| 53 | +
|
| 54 | + - uses: actions/cache@v4 |
| 55 | + id: sphinx-cache |
| 56 | + with: |
| 57 | + path: /home/runner/python-env/sphinx |
| 58 | + key: ${{ job.container.id }}-${{ hashFiles('**/requirements.txt') }} |
| 59 | + |
| 60 | + - name: Install Sphinx |
| 61 | + if: ${{ steps.sphinx-cache.outputs.cache-hit != 'true' }} |
| 62 | + run: | |
| 63 | + virtualenv /home/runner/python-env/sphinx |
| 64 | + . /home/runner/python-env/sphinx/bin/activate |
| 65 | + python3 -m pip install -r tutorials/requirements.txt |
| 66 | +
|
| 67 | + - name: Set docs target name |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + if [[ ${{ github.ref_name }} == *"/merge" ]]; then |
| 71 | + echo "AVM_DOCS_NAME=${{ github.event.pull_request.base.ref }}" | tr '/' '-' >> "$GITHUB_ENV"; |
| 72 | + else |
| 73 | + echo "AVM_DOCS_NAME=${{ github.ref_name }}" | tr '/' '-' >> "$GITHUB_ENV"; |
| 74 | + fi |
| 75 | +
|
| 76 | + - uses: actions/checkout@v4 |
| 77 | + with: |
| 78 | + repository: ${{ vars.GITHUB_REPOSITORY }} |
| 79 | + fetch-depth: 0 |
| 80 | + |
| 81 | + - name: Track all branches |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + git config --global --add safe.directory /__w/AtomVM/AtomVM |
| 85 | + for branch in `git branch -a | grep "remotes/origin" | grep -v HEAD | grep -v "${{ github.ref_name }}"`; do |
| 86 | + git branch --track ${branch#remotes/origin/} $branch |
| 87 | + done |
| 88 | +
|
| 89 | + - name: Build site |
| 90 | + id: build |
| 91 | + shell: bash |
| 92 | + run: | |
| 93 | + . /home/runner/python-env/sphinx/bin/activate |
| 94 | + git config --global --add safe.directory ${PWD} |
| 95 | + cd tutorials |
| 96 | + python generate_diagrams.py |
| 97 | + sphinx-build . build/html/ |
| 98 | + touch build/html/.nojekyll |
| 99 | +
|
0 commit comments