Skip to content

Build GitHub Pages #138

Build GitHub Pages

Build GitHub Pages #138

Workflow file for this run

name: "Build GitHub Pages"
run-name: "Build GitHub Pages"
on:
workflow_call:
push:
branches-ignore: [main]
permissions:
contents: read
env:
GH_TOKEN: ${{ github.token }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Install tools"
run: sudo apt install tidy pandoc
- name: "Install templates"
run: |
mkdir -p ~/.pandoc/templates
curl -sSL 'https://github.com/tajmone/pandoc-goodies/raw/refs/heads/master/templates/html5/github/GitHub.html5' -o ~/.pandoc/templates/GitHub.html5
- name: "Retrieve Code of Conduct"
run: curl -H "${MEDIA_TYPE_HEADER}" -H "${AUTH_TOKEN_HEADER}" -o code-of-conduct.md "${CONTENTS_ENDPOINT}/CODE_OF_CONDUCT.md"
env:
CONTENTS_ENDPOINT: '${{ github.api_url }}/repos/${{ github.repository_owner }}/.github/contents'
MEDIA_TYPE_HEADER: "Accept: application/vnd.github.raw"
AUTH_TOKEN_HEADER: "Authorization: Bearer ${{ github.token }}"
- name: "Retrieve Contribution Guidlines"
run: curl -H "${MEDIA_TYPE_HEADER}" -H "${AUTH_TOKEN_HEADER}" -o contributing.md "${CONTENTS_ENDPOINT}/CONTRIBUTING.md"
env:
CONTENTS_ENDPOINT: '${{ github.api_url }}/repos/${{ github.repository_owner }}/.github/contents'
MEDIA_TYPE_HEADER: "Accept: application/vnd.github.raw"
AUTH_TOKEN_HEADER: "Authorization: Bearer ${{ github.token }}"
- name: "Generate a changelog.md file"
run: gh api "${ENDPOINT}" --template "${TEMPLATE}" | tee changelog.md
env:
ENDPOINT: '/repos/${{ github.repository }}/releases'
TEMPLATE: |
---
lang: en
title-meta: Changelog
...
# Change Log
{{range .}}
### [{{.name}}](https://${{ github.server_url }}/${{ github.repository }}/releases/tag/{{.tag_name}})
{{.body}}
{{end}}
- name: "Create generated HTML files"
run: |
make -f - << \EOF
all: $(patsubst %.md,%.html,$(wildcard *.md */*.md */*/*.md))
rm -f header.html
%.html: %.md
pandoc --template=GitHub.html5 --include-in-header=header.html --from markdown+yaml_metadata_block+backtick_code_blocks+fenced_code_attributes+inline_notes+emoji --to html --standalone $< --output $@
EOF
- name: "Create redirect HTML files"
run: |
make -f - << \EOF
all: $(patsubst %.redirect,%.html,$(wildcard *.redirect */*.redirect */*/*.redirect))
rm -f redirect.html $(wildcard *.redirect */*.redirect */*/*.redirect)
%.html: %.redirect
@echo "Generating $@..."
$(file > $@, $(subst {{ .REDIRECT }},$(file < $<),$(file < redirect.html)))
EOF
- name: "Tidy the HTML"
run: find . -name '*.html' | xargs tidy -indent --wrap 0 --output-html yes --warn-proprietary-attributes no -quiet -modify
- name: "Archive Pages Artifact"
uses: actions/upload-artifact@v4
with:
name: pages
path: |
.
!CNAME
!.nojekyll
!.git*/**