-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,418 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#!/bin/bash -x | ||
|
||
# Docker image for pandoc | ||
if [[ -z "${PANDOCK}" ]]; then | ||
PANDOCK=ebullient/pandoc-emoji:3.1 | ||
fi | ||
# Git commit information (SHA, date, repo url) | ||
if [[ -z "${GIT_COMMIT}" ]]; then | ||
GIT_COMMIT=$(git rev-parse HEAD) | ||
fi | ||
SHA_RANGE="${GIT_COMMIT}"^.."${GIT_COMMIT}" | ||
FOOTER=$(git --no-pager log --date=short --pretty="format:%ad ✧ commit %h%n" "${SHA_RANGE}") | ||
MARK=$(git --no-pager log --date=short --pretty="format:%ad-%h%n" "${SHA_RANGE}") | ||
URL=$(gh repo view --json url --jq '.url')/ | ||
DRY_RUN=${IS_PR:-false} | ||
echo "Dry run: ${DRY_RUN}" | ||
exit 0 | ||
|
||
# Docker command and arguments | ||
ARGS="--rm -e TERM -e HOME=/data -u $(id -u):$(id -g) -v $(pwd):/data -w /data" | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
ARGS="$ARGS --platform linux/amd64" | ||
fi | ||
if [[ "${DRY_RUN}" == "true" ]]; then | ||
DOCKER="echo docker" | ||
elif [[ -z "${DOCKER}" ]]; then | ||
DOCKER=docker | ||
fi | ||
|
||
TO_CMD=${1:-nope} | ||
# Invoke command in the pandock container with common docker arguments | ||
if [[ "${TO_CMD}" == "sh" ]]; then | ||
${DOCKER} run ${ARGS} --entrypoint="" "${PANDOCK}" "$@" | ||
exit 0 | ||
fi | ||
# Invoke pandoc with common docker arguments | ||
if [[ "${TO_CMD}" != "nope" ]]; then | ||
${DOCKER} run ${ARGS} "${PANDOCK}" "$@" | ||
exit 0 | ||
fi | ||
|
||
# Convert markdown to PDF with an appended changelog | ||
function to_pdf_with_changes() { | ||
local tmpout=output/tmp/${1} | ||
mkdir -p "${tmpout}" | ||
rm -f "${tmpout}"/* | ||
shift | ||
local changes=${1} | ||
shift | ||
local changelog=${1} | ||
shift | ||
local pdfout=output/public/${1} | ||
shift | ||
rm -f "${pdfout}" | ||
|
||
changelog "${changes}" "${changelog}" | ||
to_pdf --pdf-engine-opt=-output-dir="${tmpout}" \ | ||
--pdf-engine-opt=-outdir="${tmpout}" \ | ||
-o "${pdfout}" \ | ||
"$@" "${changelog}" | ||
} | ||
|
||
# Convert markdown to PDF | ||
function to_pdf() { | ||
${DOCKER} run ${ARGS} \ | ||
"${PANDOCK}" \ | ||
-H ./.pandoc/header.tex \ | ||
-A ./.pandoc/afterBody.tex \ | ||
-d ./.pandoc/bylaws.yaml \ | ||
-M date-meta:"$(date +%B\ %d,\ %Y)" \ | ||
-V footer-left:"${FOOTER}" \ | ||
-V github:"${URL}blob/${GIT_COMMIT}/" \ | ||
"$@" | ||
} | ||
|
||
# Generate changelog from git log | ||
function changelog() { | ||
echo "# Changelog | ||
" > "${2}" | ||
git --no-pager log --reverse --date=short \ | ||
--pretty=format:"- \`%ad\` ∙ [\`%h\`](${URL}commit/%H) ∙ %s" \ | ||
origin "${GIT_COMMIT}" \ | ||
-- "${1}" >> "${2}" | ||
echo "" >> "${2}" | ||
} | ||
|
||
mkdir -p output/tmp | ||
mkdir -p output/public | ||
|
||
## BYLAWS | ||
|
||
# Sorted order of files for Bylaws | ||
BYLAWS=(./bylaws/purpose.md | ||
./bylaws/cf-membership.md | ||
./bylaws/cf-council.md | ||
./bylaws/cf-advisory-board.md | ||
./bylaws/decision-making.md | ||
./bylaws/notice-records.md | ||
./bylaws/liability-indemnification.md | ||
./bylaws/amendments.md | ||
) | ||
|
||
# Verify that bylaws files exist | ||
for x in "${BYLAWS[@]}"; do | ||
if [[ ! -f ${x} ]]; then | ||
echo "No file found at ${x}" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Convert bylaws to PDF | ||
to_pdf_with_changes \ | ||
bylaws \ | ||
./bylaws \ | ||
output/tmp/bylaws-changelog.md \ | ||
"cf-bylaws-${MARK}.pdf" \ | ||
-M title:"Commonhaus Foundation Bylaws" \ | ||
"${BYLAWS[@]}" | ||
|
||
## POLICIES | ||
|
||
# Convert individual policy to PDF | ||
function to_policy_pdf() { | ||
if [[ ! -f "./policies/${1}.md" ]]; then | ||
echo "No policy found at ./policies/${1}.md" | ||
exit 1 | ||
fi | ||
to_pdf_with_changes \ | ||
"${1}" \ | ||
"./policies/${1}.md" \ | ||
"output/tmp/${1}-changelog.md" \ | ||
"${1}-${MARK}.pdf" \ | ||
-M title-meta:"Commonhaus Foundation ${2} Policy" \ | ||
"./policies/${1}.md" | ||
} | ||
|
||
# Convert all policies to PDF | ||
to_policy_pdf conflict-of-interest "Conflict of Interest" | ||
to_policy_pdf dissolution-policy "Dissolution" | ||
to_policy_pdf ip-policy "Intellectual Property" | ||
to_policy_pdf trademark-policy "Trademark" | ||
to_policy_pdf succession-plan "Continuity and Administrative Access" | ||
|
||
# TODO: to_policy_pdf privacy "Privacy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Build PDF and publish to commonhaus.github.io | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
main-root: | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' && github.repository == 'commonhaus/foundation-draft' | ||
steps: | ||
- id: is-main-root | ||
run: echo "This is the main branch of 'commonhaus/foundation-draft'" | ||
|
||
lint: | ||
name: Check markdown links | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.5' | ||
cache: 'npm' | ||
|
||
- name: Check markdown links | ||
run: | | ||
npm ci | ||
npm run test | ||
bump: | ||
name: Update website | ||
needs: [main-root, lint] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Bump website | ||
env: | ||
GH_TOKEN: ${{ secrets.ACTIONS_PUBLISH_PAT }} | ||
run: | | ||
gh workflow run -R commonhaus/commonhaus.github.io gh-pages.yml | ||
package: | ||
name: Package PDFs | ||
needs: lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: convert md to pdf | ||
env: | ||
GIT_COMMIT: ${{ github.sha }} | ||
GH_TOKEN: ${{ github.token }} | ||
IS_PR: ${{ github.event_name == 'pull_request' }} | ||
run: ./.github/docker-build-pdf.sh | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: output | ||
path: output/public |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
*~ | ||
*.DS_Store | ||
.vscode | ||
public | ||
node_modules | ||
output | ||
node_modules |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from: gfm+emoji | ||
reader: gfm+emoji | ||
number-sections: true | ||
file-scope: true | ||
filters: | ||
- .pandoc/fix-links.lua | ||
pdf-engine: lualatex | ||
pdf-engine-opts: | ||
- '-shell-escape' | ||
template: commonhaus-eisvogel | ||
toc: true | ||
toc-depth: 3 | ||
variables: | ||
geometry: margin=1in | ||
linkcolor: blue | ||
listings: true | ||
hyperrefoptions: | ||
- linktoc=all | ||
- pdfencoding=unicode | ||
- linktocpage | ||
- bookmarks=true | ||
- bookmarksnumbered=true | ||
- bookmarksopen | ||
website: https://www.commonhaus.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function Link(el) | ||
if string.match(el.target, "http") then | ||
return el | ||
end | ||
|
||
-- Access the variables | ||
local githubUrl = tostring(PANDOC_WRITER_OPTIONS.variables["github"] or "") | ||
|
||
-- Check if the link is a relative URL... | ||
if string.match(el.target, "^%.%./") then | ||
-- Modify the link target | ||
local modifiedTarget, _ = string.gsub(el.target, "^%.%./", githubUrl) | ||
print("CFLUA: Modified link target: " .. modifiedTarget) | ||
el.target = modifiedTarget | ||
end | ||
return el | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
\usepackage{fontspec} | ||
\usepackage{moresize} | ||
\usepackage{xcolor} | ||
% Header and footer ------------------------------------------ | ||
|
||
% Read date of last commit from file | ||
% \usepackage{fancyhdr} | ||
% \newread\myread | ||
% \openin\myread=output/tmp/commit.txt | ||
% \read\myread to \lastcommit | ||
% \pagestyle{fancy} | ||
% \fancyhf{} % Clear all header and footer fields | ||
% \fancyhead[R]{\rightmark} % Right header with the section heading | ||
% \fancyfoot[L]{\lastcommit} % Left footer with your commit info | ||
% \fancyfoot[R]{\thepage} % Right footer with the page number | ||
% \renewcommand{\headrulewidth}{.2pt} % Remove the header line | ||
% \renewcommand{\footrulewidth}{.2pt} % You can set this to a non-zero value if you want a line above the footer | ||
% \fancypagestyle{plain}{ | ||
% \fancyhf{} % Clear all header and footer fields | ||
% \fancyfoot[L]{\lastcommit} % Left footer with your commit info | ||
% \renewcommand{\footrulewidth}{.2pt} % Line above the footer | ||
% } | ||
|
||
% Set the font ----------------------------------------------- | ||
|
||
% Use lua to set a fallback font for emojis | ||
\directlua{luaotfload.add_fallback | ||
("emojifallback", | ||
{ | ||
"NotoColorEmoji:mode=harf;", | ||
"DejaVuSans:mode=harf;" | ||
}) | ||
} | ||
% Make sure that the main font is sans serif | ||
% \renewcommand{\familydefault}{\sfdefault} | ||
% Setting the main font to IBM Plex Sans | ||
\setmainfont{IBMPlexSans-Regular}[ | ||
Extension = .otf , | ||
BoldFont = IBMPlexSans-Bold, | ||
ItalicFont = IBMPlexSans-Italic, | ||
BoldItalicFont = IBMPlexSans-BoldItalic, | ||
RawFeature={fallback=emojifallback} | ||
] | ||
% Setting the main font to IBM Plex Sans | ||
\setsansfont{IBMPlexSans-Regular}[ | ||
Extension = .otf , | ||
BoldFont = IBMPlexSans-Bold, | ||
ItalicFont = IBMPlexSans-Italic, | ||
BoldItalicFont = IBMPlexSans-BoldItalic, | ||
RawFeature={fallback=emojifallback} | ||
] | ||
% Setting the monospace font to IBM Plex Mono | ||
\setmonofont{IBMPlexMono-Regular}[ | ||
Extension = .otf , | ||
BoldFont = IBMPlexMono-Bold, | ||
ItalicFont = IBMPlexMono-Italic, | ||
BoldItalicFont = IBMPlexMono-BoldItalic, | ||
RawFeature={fallback=emojifallback} | ||
] |
Oops, something went wrong.