-
Notifications
You must be signed in to change notification settings - Fork 18
160 lines (143 loc) · 5.62 KB
/
publish-to-github-pages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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.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: 🔎 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'