Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and speed up the action #3

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 58 additions & 34 deletions build-pelican/action.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,72 @@
name: Build a Pelican Website
description: "Generate a Pelican website from Markdown"
inputs:
token:
description: 'Set to secrets.GITHUB_TOKEN in the workflow'
required: true
destination:
description: "Pelican Output branch"
required: true
default: "asf-site"
gfm:
description: "Uses GitHub Flavored Markdown"
default: 'asf-site'
output:
description: "Output directory in output branch"
required: false
default: 'output'
image:
description: "Docker Image"
required: false
default: 'ghcr.io/apache/infrastructure-pelican:latest'
tempdir:
description: "Name of temporary directory. Must not exist in source or output branches."
required: false
default: 'false'
default: 'output.tmp'
runs:
using: "composite"
steps:
- name: Install Pelican
run: pip3 install pelican markdown ghp-import bs4 ezt
- uses: actions/checkout@v4
with:
filter: tree:0 # This reduces download time whilst still giving access to other branches
fetch-depth: 0 # Required for multi-branch checkouts
show-progress: false # does not yet work for checkout unfortunately
- name: Identify Committer
shell: bash

# If the site uses Github Flavored Markdown, use this build branch
- name: fetch libcmark-gfm.so buildscript
run: wget https://raw.githubusercontent.com/apache/infrastructure-pelican/master/bin/build-cmark.sh -O ./build-cmark.sh
run: |
git config --global user.email "[email protected]"
git config --global user.name "Build Pelican (action)"
- name: Run Docker Pelican build => ${{ inputs.tempdir }}
shell: bash
if: ${{ inputs.gfm == 'true' }}

- name: build libcmark-gfm.so
run: /bin/bash ./build-cmark.sh
run: |
docker run --quiet -v $PWD:/site --entrypoint bash ${{ inputs.image }} \
-c "source /tmp/pelican-asf/LIBCMARKDIR.sh && python3 -m pelican content -o ${{ inputs.tempdir }}"
- name: Checkout site deploy branch
shell: bash
if: ${{ inputs.gfm == 'true' }}

- name: Generate website from markdown
run: /usr/bin/env python3 -m pelican content -o output -D
run: |
if git checkout ${{ inputs.destination }}
then
git pull origin ${{ inputs.destination }}
else
echo "branch ${{ inputs.destination }} is new; create basic site"
git config --global --add --bool push.autoSetupRemote true
git checkout --orphan ${{ inputs.destination }} -f
git rm -rf .
# TODO: does it make sense to copy the source version of the file?
# What is actually needed by the site branch?
# assume we have an asf.yaml file
git checkout origin/${{ github.ref_name }} -- .asf.yaml
git add .asf.yaml -f
fi
- name: Commit changes from ${{ inputs.tempdir }}
shell: bash
env: # in case we are using GFM (otherwise ignored)
LIBCMARKDIR: "cmark-gfm-0.28.3.gfm.12/lib"

- name: Open a PR against the staging branch
uses: peter-evans/[email protected]
with:
token: ${{ inputs.token }}
commit-message: GitHub Actions Generated Pelican Build
title: Generated Pelican Output
body: output generated
add-paths: |
output/
base: ${{ inputs.destination }}
run: |
# Remove all existing output so deletions will be captured
rm -rf ${{ inputs.output }}
git rm --quiet -r --ignore-unmatch --cached ${{ inputs.output }}/*
# replace with generated output
mv ${{ inputs.tempdir }} ${{ inputs.output }}
git diff # Show changes
git add ${{ inputs.output }}
git status
if git commit -m "Commit build products"
then
git push
else
echo "No change"
true # ensure step is successful
fi
18 changes: 18 additions & 0 deletions pelican/migration/build-pelican.ezt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[# TEMPLATE for the workflow file build-pelican.yml. Must be generated with compress-whitespace off.]
name: Build a Pelican Website
on:
workflow_dispatch:
push:
paths:
- 'content/**' # can this vary?

permissions:
contents: write # needed to commit updates to the output branch

jobs:
build-pelican:
runs-on: ubuntu-latest
steps:
- uses: 'apache/infrastructure-actions/build-pelican@main'
with:
destination: '[destination]'
18 changes: 0 additions & 18 deletions pelican/migration/build-pelican.yml

This file was deleted.

Loading