Modernize GitHub workflow #4
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: Render dpANS | ||
on: [push] | ||
jobs: | ||
render-html: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: install-platform-dependencies | ||
run: | | ||
DEBIAN_FRONTEND=noninteractive sudo apt-get update -y \ | ||
&& DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ | ||
curl libzstd1 | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
# - name: fetch-converter-binary | ||
# run: | | ||
# DOWNLOAD_URL=$(curl -s 'https://api.github.com/repos/scymtym/dpans-conversion/actions/artifacts?per_page=9' \ | ||
# | jq '[.artifacts[] | {name : .name, archive_download_url : .archive_download_url}]' \ | ||
# | jq -r '.[] | select (.name == "dpans-converter") | .archive_download_url') | ||
# echo "Downloading dpans-converter binary from ${DOWNLOAD_URL}" | ||
# curl --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
# "${DOWNLOAD_URL}" > dpans-converter.zip | ||
# unzip dpans-converter.zip | ||
# chmod +x dpans-converter | ||
- name: fetch-converter-binary | ||
run: | | ||
curl -L https://github.com/scymtym/dpans-conversion/releases/download/test-release/dpans-converter-x86-64-linux \ | ||
> dpans-converter | ||
chmod +x dpans-converter | ||
- name: render-html | ||
run: | | ||
./dpans-converter "$(pwd)/" /tmp/output/ --format html \ | ||
--title-prefix "dpANS — " \ | ||
--issue-annotations true \ | ||
--reviewer-annotations true \ | ||
--editor-annotations true \ | ||
--removable-annotations true \ | ||
--with-sidebar true | ||
- name: add-index-html | ||
run: | | ||
echo -e '<html lang="en">\n' > /tmp/output/index.html | ||
echo -e '<head>\n' >> /tmp/output/index.html | ||
echo -e '<meta charset="utf-8">\n' >> /tmp/output/index.html | ||
echo -e '<meta http-equiv="refresh" content="0;url=chap-0.xhtml"/>\n' >> /tmp/output/index.html | ||
echo -e '<link rel="canonical" href="https://s-expressionists.github.io/dpans/chap-0.xhtml"/>\n' >> /tmp/output/index.html | ||
echo -e '</head>\n' >> /tmp/output/index.html | ||
echo -e '</html>\n' >> /tmp/output/index.html | ||
- name: Create artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: /tmp/output | ||
# Deploy to GitHub pages if main branch | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
# if: github.ref == 'refs/heads/main' | ||
# Grant GITHUB_TOKEN the permissions required to make a Pages | ||
# deployment | ||
permissions: | ||
pages: write # to deploy to Pages | ||
id-token: write # to verify the deployment originates from an appropriate source | ||
# Deploy to the github-pages environment | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |