Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Publish to GitHub pages. #462

Merged
merged 4 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Pages

on:
pull_request:
push:
branches:
- master

jobs:
test:
name: GitHub Pages (en)
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: 3.11

- name: Install Dependencies
run: |
make deps

- name: Build Packages
run: |
make LANG=en

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./output/en
cname: pinout.xyz
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ LANG := $(firstword $(LANG))

all: html resources

deps:
python3 -m pip install -r requirements.txt

css:
scss resources/pinout.scss > resources/pinout.scss.css

Expand Down
26 changes: 21 additions & 5 deletions generate-html.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import os
import re
Expand Down Expand Up @@ -787,9 +787,14 @@ def interfaces_menu(current):
crumbtrail=crumbtrail
)

debug(0, '>> Saving: pinout/{}.html'.format(pin_url))
debug(0, '>> Saving: pinout/{}/index.html'.format(pin_url))

with open(os.path.join('output', lang, 'pinout', '{}.html'.format(pin_url)), 'w') as f:
try:
os.mkdir(os.path.join('output', lang, 'pinout', '{}'.format(pin_url)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't '{}'.format(pin_url) the same as just pin_url?

except FileExistsError:
pass

with open(os.path.join('output', lang, 'pinout', '{}/index.html'.format(pin_url)), 'w') as f:
f.write(pin_html)


Expand Down Expand Up @@ -876,10 +881,21 @@ def interfaces_menu(current):
if url not in ['index', '404', 'boards']:
url = os.path.join('pinout', url)

output_path = os.path.join('output', lang, f'{url}.html')
output_url = f'{url}.html'

if url == 'boards':
output_path = os.path.join('output', lang, f'{url}/index.html')
output_url = f'{url}/index.html'
try:
os.mkdir(os.path.join('output', lang, url))
except FileExistsError:
pass

if 'source' in pages[key]:
debug(0, '>> Saving: {src} => {url}.html'.format(url=url, src=pages[key]['source']))
debug(0, '>> Saving: {src} => {url}'.format(url=output_url, src=pages[key]['source']))

with open(os.path.join('output', lang, '{}.html'.format(url)), 'w') as f:
with open(output_path, 'w') as f:
f.write(html)

print('\nAll done!')
2 changes: 1 addition & 1 deletion src/en/template/footer.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<p>Spotted an error, want to add your board's pinout? <a href="https://github.com/pinout-xyz/Pinout.xyz">Contribute to Pinout.xyz at GitHub</a></p>
<p>Originally part of <a href="http://pi.gadgetoid.com">pi.gadgetoid.com</a>. Maintained by <a href="https://fosstodon.org/@gadgetoid">@[email protected]</a>.</p>
<p>Part of <a href="https://www.gadgetoid.com">gadgetoid.com</a>. Maintained by <a href="https://fosstodon.org/@gadgetoid">@[email protected]</a>.</p>
<p>Help make Pinout.xyz better- please sponsor me at <a href="https://ko-fi.com/gadgetoid">Ko-Fi</a>, <a href="https://github.com/sponsors/Gadgetoid">GitHub</a> or <a href="https://www.patreon.com/gadgetoid">Patreon</a></p>