Skip to content

Commit

Permalink
Merge pull request #462 from pinout-xyz/patch-github-pages
Browse files Browse the repository at this point in the history
CI: Publish to GitHub pages.
  • Loading branch information
Gadgetoid authored Feb 12, 2024
2 parents c79a3f9 + a72893e commit 4f5a0da
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
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)))
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">@Gadgetoid@fosstodon.org</a>.</p>
<p>Part of <a href="https://www.gadgetoid.com">gadgetoid.com</a>. Maintained by <a href="https://fosstodon.org/@gadgetoid">@Gadgetoid@fosstodon.org</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>

0 comments on commit 4f5a0da

Please sign in to comment.