Merge pull request #11 from ndw/main #36
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: publish-weblog | |
on: push | |
jobs: | |
check_branch: | |
runs-on: ubuntu-latest | |
outputs: | |
branch: ${{ steps.check_step.outputs.branch }} | |
reponame: ${{ steps.check_step.outputs.reponame }} | |
tag: ${{ steps.check_step.outputs.tag }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get branch name, etc. | |
id: check_step | |
run: | | |
raw=${{ github.repository }} | |
reponame=${raw##*/} | |
echo "reponame=$reponame" >> $GITHUB_OUTPUT | |
raw=$(git branch -r --contains ${{ github.ref }}) | |
branch=${raw##*/} | |
echo "branch=$branch" >> $GITHUB_OUTPUT | |
tag="" | |
if [ ${{ github.ref_type }} = "tag" ]; then | |
tag=${{ github.ref_name }} | |
echo "Running in $reponame on $branch for $tag" | |
else | |
echo "Running in $reponame on $branch" | |
fi | |
echo "tag=$tag" >> $GITHUB_OUTPUT | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
needs: check_branch | |
env: | |
HAVE_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN != '' }} | |
HAVE_GPGKEYURI: ${{ secrets.ACCESS_TOKEN != '' && secrets.GPGKEYURI != '' }} | |
HAVE_SAXON_EE: ${{ secrets.SAXON_PASSPHRASE != '' }} | |
CIWORKFLOW: yes | |
CI_SHA1: ${{ github.sha }} | |
CI_BUILD_NUM: ${{ github.run_number }} | |
CI_PROJECT_USERNAME: ${{ github.repository_owner }} | |
CI_PROJECT_REPONAME: ${{ needs.check_branch.outputs.reponame }} | |
CI_BRANCH: ${{ needs.check_branch.outputs.branch }} | |
CI_TAG: ${{ needs.check_branch.outputs.tag }} | |
steps: | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install epubcheck rsync libxml2-dev libxslt-dev | |
# lxml needed by html5-parser needs libxml2-dev and libxslt-dev, apparently | |
- name: Setup python dependencies | |
run: | | |
python3 -m pip install pygments==2.6.1 click cython | |
python3 -m pip install saxonche | |
python3 -m pip install --no-binary lxml html5-parser | |
- name: Checkout the main branch | |
uses: actions/checkout@v3 | |
- name: Setup SaxonEE | |
if: ${{ env.HAVE_SAXON_EE == 'true' }} | |
run: gpg --batch --yes --passphrase ${{ secrets.SAXON_PASSPHRASE }} -d tools/saxon.enc | tar zxf - | |
- name: Build | |
run: | | |
./gradlew publishWeblog -PlinkCheck=true | |
- name: Cleanup SaxonEE | |
if: ${{ env.HAVE_SAXON_EE == 'true' }} | |
run: rm -rf lib | |
- name: Deploy main to gh-pages | |
if: ${{ env.HAVE_ACCESS_TOKEN == 'true' && env.CI_BRANCH == 'main' }} | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: build/docs | |
token: ${{ secrets.ACCESS_TOKEN }} | |
branch: gh-pages | |
target-folder: /docs |