|
| 1 | +# |
| 2 | +# Copyright 2023 Winford (Uncle Grumpy) <[email protected]> |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later |
| 5 | +# |
| 6 | +# This is a workflow for atomvm/AtomVM to Publish API documentation and other content from the `doc` directory to |
| 7 | +# atomvm.net hosted on GitHub Pages |
| 8 | + |
| 9 | +name: Publish Docs |
| 10 | + |
| 11 | +# Controls when the workflow will run |
| 12 | +on: |
| 13 | + # Triggers the workflow on push request events for all branches |
| 14 | + push: |
| 15 | + |
| 16 | + # Allows you to run this workflow manually from the Actions tab |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 20 | +jobs: |
| 21 | + # This workflow contains a single job called "build" |
| 22 | + build: |
| 23 | + # The type of runner that the job will run on |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 27 | + steps: |
| 28 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 29 | + |
| 30 | + - name: Install Deps |
| 31 | + run: | |
| 32 | + sudo apt update -y |
| 33 | + DEBIAN_FRONTEND=noninteractive sudo apt install -y git cmake doxygen graphviz python3-pip python3-virtualenv python3-setuptools python3-stemmer wget |
| 34 | +
|
| 35 | + - uses: actions/cache@v3 |
| 36 | + id: sphinx-cache |
| 37 | + with: |
| 38 | + path: /home/runner/python-env/sphinx |
| 39 | + key: ${{ runner.os }}-sphinx-install |
| 40 | + |
| 41 | + - name: Install Sphinx |
| 42 | + if: steps.cache.outputs.sphinx-cache-hit != 'true' |
| 43 | + run: | |
| 44 | + python3 -m venv /home/runner/python-env/sphinx |
| 45 | + . /home/runner/python-env/sphinx/bin/activate |
| 46 | + python3 -m pip install sphinx |
| 47 | + python3 -m pip install myst-parser |
| 48 | + python3 -m pip install sphinx-rtd-theme |
| 49 | + python3 -m pip install rinohtype |
| 50 | + python3 -m pip install pillow |
| 51 | + python3 -m pip install gitpython |
| 52 | + python3 -m pip install breathe |
| 53 | + python3 -m pip install pygments |
| 54 | +
|
| 55 | + - uses: erlef/setup-beam@v1 |
| 56 | + with: |
| 57 | + otp-version: "24" |
| 58 | + elixir-version: "1.14" |
| 59 | + |
| 60 | + - name: Install rebar3 |
| 61 | + working-directory: /tmp |
| 62 | + run: | |
| 63 | + wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3 |
| 64 | + ./rebar3 local install |
| 65 | + echo "/home/runner/.cache/rebar3/bin" >> ${GITHUB_PATH} |
| 66 | +
|
| 67 | + - uses: erlef/setup-beam@v1 |
| 68 | + with: |
| 69 | + otp-version: "24" |
| 70 | + elixir-version: "1.14" |
| 71 | + |
| 72 | + - uses: actions/checkout@v3 |
| 73 | + with: |
| 74 | + repository: atomvm/AtomVM |
| 75 | + fetch-depth: 0 |
| 76 | + |
| 77 | + - uses: actions/checkout@v3 |
| 78 | + id: checkout-production |
| 79 | + with: |
| 80 | + repository: atomvm/atomvm_www |
| 81 | + ref: Production |
| 82 | + path: /home/runner/work/AtomVM/AtomVM/www |
| 83 | + |
| 84 | + - name: Build Site |
| 85 | + run: | |
| 86 | + . /home/runner/python-env/sphinx/bin/activate |
| 87 | + for remote in `git branch -r | grep -v /HEAD | grep -v ${{ github.ref_name }}`; do git checkout --track $remote; done |
| 88 | + git switch ${{ github.ref_name }} |
| 89 | + git branch |
| 90 | + mkdir build |
| 91 | + cd build |
| 92 | + cmake .. |
| 93 | + cd doc |
| 94 | + make GitHub_CI_Publish_Docs |
| 95 | +
|
| 96 | + - name: Commit files |
| 97 | + working-directory: /home/runner/work/AtomVM/AtomVM/www |
| 98 | + run: | |
| 99 | + git checkout Production |
| 100 | + git config --local user.email "[email protected]" |
| 101 | + git config --local user.name "AtomVM Doc Bot" |
| 102 | + git add . |
| 103 | + git commit -m "Update Documentation" |
| 104 | + - name: Push changes |
| 105 | + working-directory: /home/runner/work/AtomVM/AtomVM/www |
| 106 | + run: | |
| 107 | + eval `ssh-agent -t 60 -s` |
| 108 | + echo "${{ secrets.PUBLISH_ACTION_KEY }}" | ssh-add - |
| 109 | + mkdir -p ~/.ssh/ |
| 110 | + ssh-keyscan github.com >> ~/.ssh/known_hosts |
| 111 | + git remote add push_dest "[email protected]:atomvm/atomvm_www.git" |
| 112 | + git fetch push_dest |
| 113 | + git push --set-upstream push_dest Production |
| 114 | +
|
0 commit comments