Skip to content

Publish to Github Pages #23386

Publish to Github Pages

Publish to Github Pages #23386

name: Publish to Github Pages
on:
schedule:
- cron: '23 * * * *'
push:
branches:
- gh-pages
workflow_dispatch:
jobs:
build-and-publish:
name: Publish to Github Pages
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 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.7
uses: actions/setup-python@v4
with:
python-version: "3.7"
- 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: 🔎 Run link check
# id: lc
# uses: peter-evans/link-checker@v1
# with:
# args: -v -r -d ./_site/ ./_site/
#- name: 🔎 Evaluate link check
# run: exit ${{ steps.lc.outputs.exit_code }}
- name: 🚀 Deploy page
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: master
publish_dir: ./_site
enable_jekyll: false
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
- 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'