|
| 1 | +name: 🥘 Build & Deploy Docs HB |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + # Trigger on changes to docs, mkdocs config, or the workflow itself |
| 9 | + - "docs/**" |
| 10 | + - "mkdocs.yml" |
| 11 | + - ".github/workflows/build-deploy-docs.yml" |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + paths: |
| 16 | + # Trigger on changes to docs, mkdocs config, or the workflow itself |
| 17 | + - "docs/**" |
| 18 | + - "mkdocs.yml" |
| 19 | + - ".github/workflows/build-deploy-docs.yml" |
| 20 | + |
| 21 | + # Perform a release using a workflow dispatch |
| 22 | + workflow_dispatch: |
| 23 | + |
| 24 | +defaults: |
| 25 | + run: |
| 26 | + shell: bash |
| 27 | + |
| 28 | +jobs: |
| 29 | + # Run the build as part of PRs to confirm the site properly builds |
| 30 | + check_build: |
| 31 | + if: ${{ startsWith(github.ref, 'refs/pull/') }} |
| 32 | + runs-on: ubuntu-22.04 |
| 33 | + steps: |
| 34 | + - name: ⬇️ Checkout repo |
| 35 | + uses: actions/checkout@v3 |
| 36 | + |
| 37 | + # Setup Python environment |
| 38 | + - name: 🐍 Set up Python |
| 39 | + uses: actions/setup-python@v5 |
| 40 | + with: |
| 41 | + python-version: '3.x' # Use a recent Python 3 version |
| 42 | + |
| 43 | + # Install Erlang OTP 27 using kerl |
| 44 | + - name: Install Erlang OTP 27 |
| 45 | + run: | |
| 46 | + sudo apt-get update |
| 47 | + sudo apt-get install -y build-essential autoconf libncurses5-dev libssl-dev |
| 48 | + git clone https://github.com/kerl/kerl.git |
| 49 | + ./kerl/kerl build 27.0 otp-27.0 |
| 50 | + ./kerl/kerl install otp-27.0 ~/otp-27.0 |
| 51 | + echo '. ~/otp-27.0/activate' >> ~/.bashrc |
| 52 | + . ~/otp-27.0/activate |
| 53 | + echo "Erlang version:" |
| 54 | + erl -eval 'io:format("~s~n", [erlang:system_info(otp_release)]), halt().' |
| 55 | + # Install system dependencies needed for HyperBEAM |
| 56 | + - name: Install system dependencies |
| 57 | + run: | |
| 58 | + sudo apt-get update && sudo apt-get install -y --no-install-recommends \ |
| 59 | + build-essential \ |
| 60 | + cmake \ |
| 61 | + pkg-config \ |
| 62 | + ncurses-dev \ |
| 63 | + libssl-dev \ |
| 64 | + ca-certificates |
| 65 | + # Debug step - display the region with syntax error |
| 66 | + - name: Debug syntax error region |
| 67 | + run: | |
| 68 | + echo "Showing the region with syntax error in hb_message.erl:" |
| 69 | + sed -n '1440,1460p' src/hb_message.erl || echo "File not found or cannot be read" |
| 70 | + echo "Checking for syntax error fix files:" |
| 71 | + find . -name "*.erl.fix" -o -name "hb_message.erl.*" | grep -v ".beam" || echo "No fix files found" |
| 72 | + echo "Erlang version:" |
| 73 | + . ~/otp-27.0/activate && erl -eval 'io:format("~s~n", [erlang:system_info(otp_release)]), halt().' |
| 74 | + # Install rebar3 |
| 75 | + - name: Install rebar3 |
| 76 | + run: | |
| 77 | + . ~/otp-27.0/activate |
| 78 | + mkdir -p ~/.config/rebar3 |
| 79 | + curl -O https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3 |
| 80 | + sudo mv rebar3 /usr/local/bin/rebar3 |
| 81 | + . ~/otp-27.0/activate && rebar3 --version |
| 82 | + # Install Rust toolchain (needed for WASM components) |
| 83 | + - name: Install Rust and Cargo |
| 84 | + run: | |
| 85 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 86 | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 87 | + source "$HOME/.cargo/env" |
| 88 | + # Setup Node.js |
| 89 | + - name: ⎔ Setup Node |
| 90 | + uses: actions/setup-node@v3 |
| 91 | + with: |
| 92 | + node-version: 22 # Or your preferred version |
| 93 | + |
| 94 | + # Install pip dependencies and cache them |
| 95 | + - name: 📦 Install Python dependencies |
| 96 | + run: | |
| 97 | + python -m pip install --upgrade pip |
| 98 | + pip install mkdocs mkdocs-material mkdocs-git-revision-date-localized-plugin |
| 99 | + - name: 🛠 Build Docs |
| 100 | + run: | |
| 101 | + . ~/otp-27.0/activate |
| 102 | + SKIP_COMPILE=1 SKIP_EDOC=1 ./docs/build-all.sh -v |
| 103 | + # Build and deploy the artifacts to Arweave via ArDrive |
| 104 | + deploy: |
| 105 | + if: github.ref == 'refs/heads/main' |
| 106 | + runs-on: ubuntu-22.04 |
| 107 | + # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 108 | + # However, do NOT cancel in-progress runs as we want to allow these deployments to complete. |
| 109 | + concurrency: |
| 110 | + group: deploy |
| 111 | + cancel-in-progress: false |
| 112 | + steps: |
| 113 | + - name: ⬇️ Checkout repo |
| 114 | + uses: actions/checkout@v3 |
| 115 | + |
| 116 | + # Setup Python environment |
| 117 | + - name: 🐍 Set up Python |
| 118 | + uses: actions/setup-python@v5 |
| 119 | + with: |
| 120 | + python-version: '3.x' |
| 121 | + |
| 122 | + # Install Erlang OTP 27 using kerl |
| 123 | + - name: Install Erlang OTP 27 |
| 124 | + run: | |
| 125 | + sudo apt-get update |
| 126 | + sudo apt-get install -y build-essential autoconf libncurses5-dev libssl-dev |
| 127 | + git clone https://github.com/kerl/kerl.git |
| 128 | + ./kerl/kerl build 27.0 otp-27.0 |
| 129 | + ./kerl/kerl install otp-27.0 ~/otp-27.0 |
| 130 | + echo '. ~/otp-27.0/activate' >> ~/.bashrc |
| 131 | + . ~/otp-27.0/activate |
| 132 | + echo "Erlang version:" |
| 133 | + erl -eval 'io:format("~s~n", [erlang:system_info(otp_release)]), halt().' |
| 134 | + # Install system dependencies needed for HyperBEAM |
| 135 | + - name: Install system dependencies |
| 136 | + run: | |
| 137 | + sudo apt-get update && sudo apt-get install -y --no-install-recommends \ |
| 138 | + build-essential \ |
| 139 | + cmake \ |
| 140 | + pkg-config \ |
| 141 | + ncurses-dev \ |
| 142 | + libssl-dev \ |
| 143 | + ca-certificates |
| 144 | + # Debug step - display the region with syntax error |
| 145 | + - name: Debug syntax error region |
| 146 | + run: | |
| 147 | + echo "Showing the region with syntax error in hb_message.erl:" |
| 148 | + sed -n '1440,1460p' src/hb_message.erl || echo "File not found or cannot be read" |
| 149 | + echo "Checking for syntax error fix files:" |
| 150 | + find . -name "*.erl.fix" -o -name "hb_message.erl.*" | grep -v ".beam" || echo "No fix files found" |
| 151 | + echo "Erlang version:" |
| 152 | + . ~/otp-27.0/activate && erl -eval 'io:format("~s~n", [erlang:system_info(otp_release)]), halt().' |
| 153 | + # Install rebar3 |
| 154 | + - name: Install rebar3 |
| 155 | + run: | |
| 156 | + . ~/otp-27.0/activate |
| 157 | + mkdir -p ~/.config/rebar3 |
| 158 | + curl -O https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3 |
| 159 | + sudo mv rebar3 /usr/local/bin/rebar3 |
| 160 | + . ~/otp-27.0/activate && rebar3 --version |
| 161 | + # Install Rust toolchain (needed for WASM components) |
| 162 | + - name: Install Rust and Cargo |
| 163 | + run: | |
| 164 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 165 | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 166 | + source "$HOME/.cargo/env" |
| 167 | + # Install pip dependencies and cache them |
| 168 | + - name: 📦 Install Python dependencies |
| 169 | + run: | |
| 170 | + python -m pip install --upgrade pip |
| 171 | + pip install mkdocs mkdocs-material mkdocs-git-revision-date-localized-plugin |
| 172 | + # Setup Node.js (needed for npx deploy command) |
| 173 | + - name: ⎔ Setup Node |
| 174 | + uses: actions/setup-node@v3 |
| 175 | + with: |
| 176 | + node-version: 22 # Or your preferred version |
| 177 | + |
| 178 | + - name: 👀 Env |
| 179 | + run: | |
| 180 | + echo "Event name: ${{ github.event_name }}" |
| 181 | + echo "Git ref: ${{ github.ref }}" |
| 182 | + echo "GH actor: ${{ github.actor }}" |
| 183 | + echo "SHA: ${{ github.sha }}" |
| 184 | + VER=`node --version`; echo "Node ver: $VER" |
| 185 | + VER=`npm --version`; echo "npm ver: $VER" |
| 186 | + . ~/otp-27.0/activate && erl -eval 'io:format("Erlang OTP version: ~s~n", [erlang:system_info(otp_release)]), halt().' |
| 187 | + - name: 🛠 Build Docs |
| 188 | + id: build_artifacts |
| 189 | + run: | |
| 190 | + . ~/otp-27.0/activate |
| 191 | + SKIP_COMPILE=1 SKIP_EDOC=1 ./docs/build-all.sh -v |
| 192 | + touch mkdocs-site/.nojekyll |
| 193 | + echo "artifacts_output_dir=mkdocs-site" >> $GITHUB_OUTPUT |
| 194 | + - name: 💾 Publish to Arweave |
| 195 | + id: publish_artifacts |
| 196 | + run: | |
| 197 | + npx permaweb-deploy \ |
| 198 | + --arns-name=dps-testing-facility \ |
| 199 | + --ant-process=${{ secrets.ANT_PROCESS }} \ |
| 200 | + --deploy-folder=${ARTIFACTS_OUTPUT_DIR} |
| 201 | + env: |
| 202 | + DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} |
| 203 | + ARTIFACTS_OUTPUT_DIR: ${{ steps.build_artifacts.outputs.artifacts_output_dir }} |
| 204 | + ANT_PROCESS: ${{ secrets.ANT_PROCESS }} |
0 commit comments