Skip to content

Commit

Permalink
ci: build by list
Browse files Browse the repository at this point in the history
  • Loading branch information
TechCiel committed Oct 30, 2023
1 parent 876698d commit 6663cb7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: build
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install markdown pyyaml beautifulsoup4
- name: Build all documentation
run: |
export TUNA_TEMP_DIR=$(mktemp -d)
cat enabled.txt | xargs python global/compile.py -v --lang zh -C dom -C tuna
git checkout transpiled
mv $TUNA_TEMP_DIR/* .
- name: Commit changes
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add *.md
git commit -am "sync global documentations" && git push || echo "No changes to commit"
14 changes: 9 additions & 5 deletions tuna.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import os
from pathlib import Path


outdir = Path(os.environ.get('TUNA_TEMP_DIR', './tuna/'))
os.makedirs(outdir, exist_ok=True)


def process(html, config, project, *_):
md = f"""---
Expand All @@ -7,6 +13,7 @@ def process(html, config, project, *_):
mirrorid: {config.get('mirrorid', project)}
---
""" + """
{% raw %}
<!-- 本 markdown 从 tuna/mirrorz-help-ng 自动生成,如需修改请参阅该仓库 -->
<style>.z-help tmpl { display: none }</style>
Expand All @@ -31,14 +38,11 @@ def process(html, config, project, *_):
</div>
</form>
</div>
{% raw %}
""" + html + """
{% endraw %}
<script src="/static/js/mustache.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/zdocs.js?{{ site.data['hash'] }}"></script>
{% endraw %}
"""
os.makedirs('tuna', exist_ok=True)
with open(f'tuna/1970-01-01-{config.get("permalink", project)}.md', 'w') as f:
with open(outdir/f'1970-01-01-{config.get("permalink", project)}.md', 'w') as f:
f.write(md)
return html

0 comments on commit 6663cb7

Please sign in to comment.