Skip to content

Commit

Permalink
👷 revise pdf/doc builds + triggers
Browse files Browse the repository at this point in the history
- clear split between pdf/docx build and cross-repo trigger
- remove redundancies in doc creation script
- notice (content push) should happen more often than not
- linter can be constrained to md & yaml
  • Loading branch information
ebullient committed Dec 12, 2024
1 parent 431ea37 commit ab1ac9f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 112 deletions.
7 changes: 4 additions & 3 deletions .github/cf-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ notice:
- edited
- closed
paths:
- agreements/project-contribution/*
- bylaws/*
- policies/*
label: ["!notice"]
Expand Down Expand Up @@ -95,11 +96,11 @@ voting:
- source: CONTACTS.yaml
repo: commonhaus/foundation
mapping:
- field: project
primary:
- field: project
primary:
data: egc
team: commonhaus/cf-egc
secondary:
secondary:
data: egc-second
team: commonhaus/cf-egc-second
exclude_login:
Expand Down
131 changes: 49 additions & 82 deletions .github/docker-build-pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,55 +82,29 @@ if [[ "${TO_CMD}" != "noargs" ]]; then
fi

# Convert markdown to PDF with an appended changelog
function to_pdf_pattern() {
local tmpout=output/tmp/${1}
shift
local pdfout=output/public/${1}
shift
local relative_path=${1}
shift

mkdir -p "${tmpout}"
rm -f "${tmpout}"/*
rm -f "${pdfout}"

# Use mounted volume paths
run_pdf --pdf-engine-opt=-output-dir="./${tmpout}" \
--pdf-engine-opt=-outdir="./${tmpout}" \
-o "./${pdfout}" \
-V dirname:"${relative_path}" \
"$@"
}

# Convert markdown to PDF with an appended changelog
# to_pdf ./TRADEMARKS.md trademark-list ./ "Commonhaus Foundation Trademark List"
# working-dir is used to resolve resources in the file
# to_pdf pdf-basename cwd sources+args
# to_pdf trademark-list ./ sources+args
# to_pdf x ./policies sources+args
# to_pdf cf-bylaws ./bylaws sources+args
function to_pdf() {
if [[ ! -f "${1}" ]]; then
echo "No source file found at ${1}"
exit 1
fi
local source=${1}
shift
local basename=${1}
shift
local relative_path=${1}
shift
local title=${1}
shift

local tmpout=output/tmp/${basename}
local tmpout=./output/tmp/${basename}
mkdir -p "${tmpout}"
rm -f "${tmpout}"/*
local pdfout=output/public/${basename}.pdf
local pdfout=./output/public/${basename}.pdf
rm -f "${pdfout}"

# Use mounted volume paths
run_pdf --pdf-engine-opt=-output-dir="./${tmpout}" \
--pdf-engine-opt=-outdir="./${tmpout}" \
-o "./${pdfout}" \
-M title:"${title}" \
run_pdf --pdf-engine-opt=-output-dir="${tmpout}" \
--pdf-engine-opt=-outdir="${tmpout}" \
-V dirname:"${relative_path}" \
"${source}"
-o "${pdfout}" \
"$@"
}

# Convert markdown to PDF
Expand All @@ -150,11 +124,9 @@ function run_pdf() {
function run_docx() {
${DOCKER} run ${ARGS} \
"${PANDOCK}" \
-d ./.pandoc/agreements.yaml \
-M date-meta:"$(date +%B\ %d,\ %Y)" \
-V github:"${URL}" \
-o "$1" \
"$2"
"$@"

echo "$?"
}
Expand All @@ -164,35 +136,21 @@ mkdir -p output/public

## BYLAWS

# Sorted order of files for Bylaws
BYLAWS=(
./bylaws/1-preface.md
./bylaws/2-purpose.md
./bylaws/3-cf-membership.md
./bylaws/4-cf-council.md
./bylaws/5-cf-advisory-board.md
./bylaws/6-decision-making.md
./bylaws/7-notice-records.md
./bylaws/8-indemnification-dissolution.md
./bylaws/9-amendments.md
)

if [[ -z "${SKIP_BYLAWS}" ]]; then
# 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_pattern \
bylaws \
"cf-bylaws.pdf" \
# Convert bylaws to PDF
to_pdf \
"cf-bylaws" \
"./bylaws/" \
-M title:"Bylaws" \
"${BYLAWS[@]}"
-M "title:Bylaws" \
./bylaws/1-preface.md \
./bylaws/2-purpose.md \
./bylaws/3-cf-membership.md \
./bylaws/4-cf-council.md \
./bylaws/5-cf-advisory-board.md \
./bylaws/6-decision-making.md \
./bylaws/7-notice-records.md \
./bylaws/8-indemnification-dissolution.md \
./bylaws/9-amendments.md
fi

## POLICIES
Expand All @@ -203,27 +161,34 @@ function to_policy_pdf() {
echo "No policy found at ./policies/${1}.md"
exit 1
fi
to_pdf_pattern \
# to_pdf pdf-basename working-dir title ... whatever else
to_pdf \
"${1}" \
"${1}.pdf" \
"./policies/" \
-M title:"${2} Policy" \
-M "title:${2} Policy" \
"./policies/${1}.md"
}

if [[ -z "${SKIP_POLICIES}" ]]; then
# Convert all policies to PDF
to_policy_pdf code-of-conduct "Code of Conduct"
to_policy_pdf conflict-of-interest "Conflict of Interest"
to_policy_pdf ip-policy "Intellectual Property"
to_policy_pdf trademark-policy "Trademark"

to_pdf ./TRADEMARKS.md trademark-list ./ "Trademark List"
# Convert policies to PDF
# function source file (no extension) <title> Policy
to_policy_pdf code-of-conduct "Code of Conduct"
to_policy_pdf conflict-of-interest "Conflict of Interest"
to_policy_pdf ip-policy "Intellectual Property"
to_policy_pdf trademark-policy "Trademark"

# to_pdf pdf-file-name cwd the rest...
to_pdf trademark-list ./ -M "title:Trademark List" ./TRADEMARKS.md
fi

## AGREEMENTS

function to_agreement_doc() {
local config="./.pandoc/agreements.yaml"
if [[ "${1}" == "true" ]]; then
config="./.pandoc/draft-agreements.yaml"
fi
shift
local input=${1}
if [[ ! -f "./agreements/${input}.md" ]]; then
echo "No agreement found at ./agreements/${input}.md"
Expand All @@ -234,15 +199,17 @@ function to_agreement_doc() {
output=$(basename ${input})
fi
run_docx \
"./output/public/${output}.docx" \
-o "./output/public/${output}.docx" \
-d "./.pandoc/agreements.yaml" \
"./agreements/${input}.md"
}

if [[ -z "${SKIP_AGREEMENTS}" ]]; then
to_agreement_doc bootstrapping/bootstrapping bootstrapping-agreement
# to_agreement_doc project-contribution/asset-transfer-agreement
# to_agreement_doc project-contribution/fiscal-sponsorship-agreement
# to_agreement_doc project-contribution/fiscal-sponsorship-terms-and-conditions
# function is_draft markdown source (no extension)
to_agreement_doc false bootstrapping/bootstrapping bootstrapping-agreement
# to_agreement_doc true project-contribution/asset-transfer-agreement
# to_agreement_doc true project-contribution/fiscal-sponsorship-agreement
# to_agreement_doc true project-contribution/fiscal-sponsorship-terms-and-conditions
fi

ls -al output/public
8 changes: 8 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ name: Validate markdown and YAML

on:
pull_request:
paths:
- '*.md'
- '*.yml'
- '*.yaml'
push:
branches:
- main
paths:
- '*.md'
- '*.yml'
- '*.yaml'
workflow_dispatch:

env:
Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/notice.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
name: Push discussions and PR activity to commonhaus.github.io
name: Push activity to commonhaus.github.io

on:
discussion:
pull_request_target:
types: [opened, edited, reopened, closed]
paths:
- '*.md'
- '*.yaml'
- 'bylaws/**'
- 'policies/**'
paths-ignore:
- '.*'
- 'elections'
- 'templates'
push:
branches:
- main
paths:
- '*.md'
- '*.yaml'
- 'bylaws/**'
- 'policies/**'
paths-ignore:
- '.*'
- 'elections'
- 'templates'
workflow_dispatch:

permissions: {}
Expand All @@ -33,3 +31,4 @@ jobs:
GH_TOKEN: ${{ secrets.ACTIONS_PUBLISH_PAT }}
run: |
gh workflow run -R commonhaus/commonhaus.github.io push-content.yml
19 changes: 3 additions & 16 deletions .github/workflows/build.yaml → .github/workflows/pdf-build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build PDF and publish to commonhaus.github.io
name: Build PDF / Docx

on:
pull_request:
Expand Down Expand Up @@ -31,20 +31,7 @@ jobs:
steps:
- if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'commonhaus/foundation'
id: is-main-root
run: echo "test=true" >> "$GITHUB_OUTPUT"

update-website:
needs: main-root
runs-on: ubuntu-latest
if: ${{ needs.main-root.outputs.is-main }}
permissions:
actions: read
steps:
- name: Bump website
env:
GH_TOKEN: ${{ secrets.ACTIONS_PUBLISH_PAT }}
run: |
gh workflow run -R commonhaus/commonhaus.github.io push-content.yml
run: echo "test=true" >> "$GITHUB_OUTPUT

package:
name: Package PDFs
Expand Down Expand Up @@ -98,4 +85,4 @@ jobs:
# These must be done separately to correctly toggle draft flag
gh release edit SNAPSHOT -t "PDF snapshot" --prerelease
gh release view SNAPSHOT
gh release edit SNAPSHOT --draft=false
gh release edit SNAPSHOT --draft=false

0 comments on commit ab1ac9f

Please sign in to comment.