Merge pull request #898 from Nadrieril/fix-some-binder-crashes #253
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: Deploy to GH Pages | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main] | |
jobs: | |
build-documentation: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Build docs | |
run: nix build .#hax.docs --out-link ./_site | |
- name: Upload Pages artifact | |
uses: actions/upload-pages-artifact@v2 | |
# deploys the result of `build` | |
# this job is a copy paste from <https://github.com/actions/deploy-pages> | |
deploy-documentation: | |
# Add a dependency to the build job | |
needs: build-documentation | |
# 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 }} | |
# Specify runner + deployment step | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action | |
# Builds and deploy "external" GH pages: pushes to the repos | |
# `hacspec/hacspec.github.io` and `hacspec/book` | |
build-and-deploy-external-gh-pages: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: hax | |
- uses: actions/checkout@v4 | |
with: | |
repository: "hacspec/hacspec.github.io" | |
path: hacspec.github.io | |
token: ${{secrets.PUSH_HACSPEC_GITHUB_TOKEN}} | |
- uses: actions/checkout@v4 | |
with: | |
repository: "hacspec/book" | |
path: book | |
token: ${{secrets.PUSH_HACSPEC_GITHUB_TOKEN}} | |
- uses: DeterminateSystems/nix-installer-action@main | |
- name: Configure git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Patch and push `README.md` in `hacspec.github.io` | |
run: | | |
( | |
README_ORIGINAL="https://github.com/hacspec/hax/blob/main/README.md" | |
echo "<!-- WARNING: a GitHub action periodically replaces this file with ${README_ORIGINAL}. Do not make any modification to this file, instead make a PR to ${README_ORIGINAL} -->" | |
echo "" | |
cat hax/README.md | |
) > hacspec.github.io/README.md | |
cd hacspec.github.io | |
# Replace the `🌐 Website` link to a GitHub link | |
sed -i 's#.*🌐 Website.*# <a href="https://github.com/hacspec/hax">🔗 GitHub</a> |#' README.md | |
# Replace relative links to absolute links | |
sed -i 's|(\./|(https://github.com/hacspec/hax/tree/main/|g' README.md | |
git add -A | |
if git commit -m "Readme update"; then | |
git push https://$USERNAME:$PUSH_HACSPEC_GITHUB_TOKEN@github.com/hacspec/hacspec.github.io | |
fi | |
- name: Regenerate and push the book | |
run: | | |
nix build ./hax#hax-book -o result-hax-book | |
HAX_COMMIT=$(git -C ./hax rev-parse --short HEAD) | |
mkdir hax-book | |
rsync -rq --no-perms --chown=$(id -un):$(id -gn) "$(realpath result-hax-book)/" hax-book | |
mv book/.git hax-book/.git | |
cd hax-book | |
{ | |
echo "# Warning: this repository only contains generated files" | |
echo "The sources of the book are in https://github.com/hacspec/hax/tree/main/book" | |
echo "Please file issues, and push PRs to https://github.com/hacspec/hax." | |
} > README.md | |
git add -A | |
if git commit -m "Book update (generated from hacspec/hax@$HAX_COMMIT)"; then | |
git push https://$USERNAME:$PUSH_HACSPEC_GITHUB_TOKEN@github.com/hacspec/book | |
fi | |
env: | |
PUSH_HACSPEC_GITHUB_TOKEN: ${{secrets.PUSH_HACSPEC_GITHUB_TOKEN}} | |
USERNAME: github-actions[bot] |