Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoCostaIFG committed Dec 5, 2024
0 parents commit 51d1788
Show file tree
Hide file tree
Showing 38 changed files with 11,626 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/joplin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Get Wiki contents from Joplin

on:
push:
branches: [ "master" ]
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Login and sync Joplin Wiki notebook
env:
JOPLIN_CONFIG: ${{ secrets.JOPLIN_CONFIG }}
run: |
echo "$JOPLIN_CONFIG" | npx joplin config --import
npx joplin sync
rm -rf src/
npx joplin export --format md --notebook Wiki src/
- name: Build mdbook summary
run: ./generate_summary.py

- uses: EndBug/add-and-commit@v9 # You can change this to use a specific version.
with:
add: 'src'
default_author: github_actions
message: 'Sync wiki contents with upstream'
pathspec_error_handling: exitImmediately
53 changes: 53 additions & 0 deletions .github/workflows/mdbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy mdBook site to Pages

on:
workflow_run:
workflows: ['Get Wiki contents from Joplin']
types: [completed]
branches:
- 'master'

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
env:
MDBOOK_VERSION: 0.4.36
steps:
- uses: actions/checkout@v4
- name: Install mdBook
run: |
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
rustup update
cargo install --version ${MDBOOK_VERSION} mdbook
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Build with mdBook
run: mdbook build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./book

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
131 changes: 131 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
book
6 changes: 6 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[book]
authors = ["JoaoCostaIFG"]
language = "en"
multilingual = false
src = "src"
title = "JoaoCostaIFG Wiki"
40 changes: 40 additions & 0 deletions generate_summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3

from pathlib import Path

src = Path("src")
wiki = src.joinpath("Wiki")
summary = src.joinpath("SUMMARY.md")

def build_dir(entry: Path) -> str:
parts = entry.parts
indent = "\t" * (len(parts) - 3) # dont count Wiki and filename
return indent + f"- [{entry.parent.name}]({entry})\n"

def build_entry(entry: Path) -> str:
parts = entry.parts
indent = "\t" * (len(parts) - 2) # dont count Wiki and filename
return indent + f"- [{entry.name}]({entry})\n"


with open(summary, "w+", encoding="utf-8") as f:
f.write("""# Summary
[Introduction](Wiki/README.md)
""")

last_dir = None
pathlist = wiki.rglob("*.md")
for path in pathlist:
if path.name.lower() == "readme.md":
continue

path_parts = path.parts[1:]
trimed_path = Path(*path_parts)

if trimed_path.parent != last_dir and trimed_path.parent.name != wiki.name:
last_dir = trimed_path.parent
f.write(build_dir(last_dir.joinpath("README.md")))

f.write(build_entry(trimed_path))
Loading

0 comments on commit 51d1788

Please sign in to comment.