First templating tests (#62) #14
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
--- | |
name: marp-and-mkdocs-to-pages | |
concurrency: marp-and-mkdocs-to-pages | |
on: | |
push: | |
branches: [ '**' ] | |
paths: | |
- slides/** | |
- docs/** | |
- mkdocs.yml | |
- img/** | |
- .github/workflows/publish-pages-on-forks.yml | |
# also trigger if lab archives changed | |
- labs/** | |
- .devcontainer/** | |
workflow_dispatch: | |
branches: [ '**' ] | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
build: | |
if: github.repository != 'aristanetworks/aclabs' | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code ✅ | |
uses: actions/checkout@v4 | |
- name: find-branch | |
id: find_branch | |
run: | | |
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
- name: Replace URLs to match git repo ✂️ | |
run: | | |
grep -rl '${localEnv:GITHUB_REPOSITORY}' . --exclude-dir .git --exclude-dir .cp | xargs sed -i 's@${localEnv:GITHUB_REPOSITORY}@'"${{ github.repository }}"'@g' | |
grep -rl '{{gh.repo_name}}' . --exclude-dir .git --exclude-dir .cp | xargs sed -i 's/{{gh.repo_name}}/'"${{ github.event.repository.name }}"'/g' | |
grep -rl '{{gh.org_name}}' . --exclude-dir .git --exclude-dir .cp | xargs sed -i 's/{{gh.org_name}}/'"${{ github.repository_owner }}"'/g' | |
grep -rl '{{gh.repository}}' . --exclude-dir .git --exclude-dir .cp | xargs sed -i 's@{{gh.repository}}@'"${{ github.repository }}"'@g' | |
grep -rl '{{gh.branch}}' . --exclude-dir .git --exclude-dir .cp | xargs sed -i 's@{{gh.branch}}@'"${{ steps.find_branch.outputs.branch }}"'@g' | |
- name: Setup Python3 🐍 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Build MkDocs Site | |
run: | | |
pip install mkdocs-material | |
pip install mkdocs-macros-plugin | |
pip install mdx_truly_sane_lists | |
pip install mkdocs-glightbox | |
mkdocs build | |
- name: Build Directories and Copy images 🖼️ | |
run: | | |
mkdir site/slides \ | |
&& mkdir site/slides/assets \ | |
&& mkdir site/pdfs \ | |
&& cp -R slides/assets/img site/slides/assets/img | |
- name: Build HTML from Marp 🔨 | |
uses: docker://marpteam/marp-cli:v3.4.0 | |
with: | |
args: --theme-set ./assets/themes/ --html --input-dir slides/ -o site/slides/ | |
env: | |
MARP_USER: root:root | |
- name: Build PDF from marp_slides.md 🔨 | |
uses: docker://marpteam/marp-cli:v3.4.0 | |
with: | |
args: --theme-set ./assets/themes/ --html --pdf --allow-local-files --input-dir slides/ -o site/pdfs/ | |
env: | |
MARP_USER: root:root | |
- name: Add lab archive for local download | |
run: | | |
mkdir site/lab_archives | |
mkdir temp_labs | |
for DEMO_DIR in labs/* | |
do | |
DEMO_NAME="${DEMO_DIR##*/}" | |
mkdir temp_labs/${DEMO_NAME} | |
mkdir temp_labs/${DEMO_NAME}/.devcontainer | |
mkdir temp_labs/${DEMO_NAME}/labs | |
cp -r .devcontainer/${DEMO_NAME}/* temp_labs/${DEMO_NAME}/.devcontainer/ | |
cp -r labs/${DEMO_NAME}/ temp_labs/${DEMO_NAME}/labs/ | |
tar -czvf site/lab_archives/${DEMO_NAME}.tar.gz --directory temp_labs/ ${DEMO_NAME} | |
done | |
rm -rf temp_labs/ | |
- name: Setup Pages 📖 | |
uses: actions/configure-pages@v5 | |
- name: Upload artifact 🔼 | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./site/ | |
- name: Deploy to GitHub Pages 🚀 | |
id: deployment | |
uses: actions/deploy-pages@v4 |