Build, validate & deploy page #30565
This file contains hidden or 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
| name: Build, validate & deploy page | |
| on: | |
| schedule: | |
| - cron: "23 * * * *" | |
| push: | |
| branches: | |
| - gh-pages | |
| workflow_dispatch: | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| name: Build page | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: ⬇ Fetch rpi-imager.json snippet for stable | |
| uses: OctoPrint/actions/fetch-rpi-imager-snippet@main | |
| with: | |
| token: "${{ secrets.GITHUB_TOKEN }}" | |
| owner: OctoPrint | |
| repo: OctoPi-UpToDate | |
| output: /tmp/rpi-imager-stable.json | |
| ignoreRegex: "rc|branch|mark:untested|mark:ignored" | |
| - name: ⬇ Fetch rpi-imager.json snippet for new camera stack | |
| uses: OctoPrint/actions/fetch-rpi-imager-snippet@main | |
| with: | |
| token: "${{ secrets.GITHUB_TOKEN }}" | |
| owner: OctoPrint | |
| repo: OctoPi-UpToDate | |
| output: /tmp/rpi-imager-camerastack.json | |
| includePrereleases: true | |
| matchRegex: "camera-streamer" | |
| ignoreRegex: "rc|mark:untested" | |
| - name: 🔨 Preprocess the snippets | |
| run: | | |
| if [ -f /tmp/rpi-imager-stable.json ]; then | |
| description=$(jq -r '.name' /tmp/rpi-imager-stable.json) | |
| jq '. + {"name": "OctoPi (stable)", "description": "'"$description"'", "init_format": "systemd"}' /tmp/rpi-imager-stable.json > /tmp/rpi-imager-stable.json.tmp && mv /tmp/rpi-imager-stable.json.tmp /tmp/rpi-imager-stable.json | |
| fi | |
| if [ -f /tmp/rpi-imager-camerastack.json ]; then | |
| description=$(jq -r '.name' /tmp/rpi-imager-camerastack.json) | |
| jq '. + {"name": "OctoPi (new experimental camera stack)", "description": "'"$description"'", "init_format": "systemd"}' /tmp/rpi-imager-camerastack.json > /tmp/rpi-imager-camerastack.json.tmp && mv /tmp/rpi-imager-camerastack.json.tmp /tmp/rpi-imager-camerastack.json | |
| fi | |
| - name: 🔨 Build rpi-imager.json | |
| uses: OctoPrint/actions/stitch-rpi-imager-snippets@main | |
| with: | |
| output: ./files/rpi-imager.json | |
| snippets: /tmp/rpi-imager-stable.json /tmp/rpi-imager-camerastack.json | |
| #- name: 🔨 Build rpi-imager-nightlies.json | |
| # run: | | |
| # OUTPUT=./files/rpi-imager-nightlies.json | |
| # N=5 | |
| # | |
| # nightlies="https://unofficialpi.org/Distros/OctoPi/nightly/" | |
| # page=$(curl --silent $nightlies) | |
| # | |
| # last=$(echo $page | grep -o 'href="[^"]*\.zip"' | cut -d '"' -f 2 | uniq | tail -n $N | sort -r) | |
| # | |
| # cat <<EOF > $OUTPUT | |
| # { | |
| # "os_list": [ | |
| # EOF | |
| # comma="" | |
| # for f in $last; do | |
| # download="$nightlies$f" | |
| # size=$(curl -I --silent "$download" | grep -i "content-length" | cut -d ' ' -f 2) | |
| # date=$(echo $f | cut -d '_' -f 1) | |
| # | |
| # cat <<EOF >> $OUTPUT | |
| # $comma | |
| # { | |
| # "name": "OctoPi nightly $date", | |
| # "description": "OctoPi nightly from $date", | |
| # "url": "$download", | |
| # "icon": "https://octoprint.org/files/rpi-imager-nightlies.png", | |
| # "release_date": "$date", | |
| # "image_download_size": $size, | |
| # "init_format": "systemd" | |
| # } | |
| # EOF | |
| # comma="," | |
| # done | |
| # | |
| # cat <<EOF >> $OUTPUT | |
| # ] | |
| # } | |
| # EOF | |
| # | |
| #- name: 🔨 Extend rpi-imager.json | |
| # run: | | |
| # # add nightlies | |
| # jq '.os_list += [{"name": "OctoPi Nightlies","description": "Nightly OctoPi builds, untested, bleeding edge","subitems_url": "https://octoprint.org/files/rpi-imager-nightlies.json"}]' ./files/rpi-imager.json > ./files/rpi-imager.json.tmp && mv ./files/rpi-imager.json.tmp ./files/rpi-imager.json | |
| # | |
| # echo "Generated rpi-imager.json:" | |
| # cat ./files/rpi-imager.json | |
| - name: 🐍 Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: 🐍 Install requirements | |
| run: | | |
| pip install -r ./.github/scripts/requirements.txt | |
| - name: 🔁 Update octopi.yaml | |
| run: | | |
| cd .github/scripts | |
| python update_page_from_rpiimagerjson.py | |
| cat ../../_data/octopi.yaml | |
| - name: 💎 Set up Ruby 3 | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.0" | |
| bundler-cache: true | |
| - name: 🔨 Build page | |
| run: | | |
| bundle exec jekyll build --future --trace | |
| - name: ⬆ Upload pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./_site | |
| - name: 📧 Discord success notification | |
| env: | |
| DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} | |
| uses: Ilshidur/action-discord@master | |
| with: | |
| args: "☑️ Page build for octoprint.org was successful" | |
| - name: 📧 Discord failure notification | |
| if: failure() | |
| env: | |
| DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} | |
| uses: Ilshidur/action-discord@master | |
| with: | |
| args: "🚫 Page build for octoprint.org failed" | |
| deploy: | |
| name: "Deploy" | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.repository == 'OctoPrint/octoprint.org' && github.event_name != 'pull_request' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |