This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
Publish preview PDF #1747
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 preview PDF | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
schedule: | |
- cron: '3 0,6,12,18 * * *' | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow one concurrent deployment | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build preview PDF | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout master | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Pages | |
uses: actions/configure-pages@v2 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install typst | |
# run: 'sudo apt-get update && sudo apt install -y ripgrep wget curl && (curl -s https://api.github.com/repos/typst/typst/releases | rg "browser_download_url.*typst-x86_64-unknown-linux-gnu.tar.gz" | head -1 | cut -d : -f 2,3 | tr -d \" | wget -qi -) && tar xf typst-x86_64-unknown-linux-gnu.tar.gz && sudo mv typst-x86_64-unknown-linux-gnu/typst /usr/local/bin/typst' | |
run: 'cargo install --git https://github.com/typst/typst typst-cli' | |
- name: Build PDF | |
run: 'mkdir build && typst compile --font-path fonts thesis.typ build/thesis.pdf' | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: 'build' | |
deploy-github: | |
name: Deploy to GitHub Pages | |
needs: build | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }}thesis.pdf | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 | |
deploy-gitee: | |
name: Deploy to Gitee Pages | |
needs: build | |
runs-on: ubuntu-latest | |
environment: | |
name: gitee-pages | |
url: https://howardlau.gitee.io/sysu-thesis-typst/thesis.pdf | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: github-pages | |
- name: Extract artifact | |
run: | | |
mkdir -p $RUNNER_TEMP/gitee_pages | |
tar -C $RUNNER_TEMP/gitee_pages -xf artifact.tar | |
- name: Deploy to Gitee Pages | |
env: | |
GITEE_RSA_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} | |
run: | | |
mkdir -p ~/.ssh | |
echo "$GITEE_RSA_PRIVATE_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
git config --global user.name "Howard Lau" | |
git config --global user.email "howardlau1999@hotmail.com" | |
cd $RUNNER_TEMP/gitee_pages | |
git init | |
git checkout -b gh-pages | |
echo "<html><head><meta http-equiv=\"refresh\" content=\"0; url=thesis.pdf\" /></head></html>" > index.html | |
git add . | |
git commit -m "Deploy to Gitee Pages" | |
export GIT_SSH_COMMAND="ssh -v -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no" | |
git push --force --quiet git@gitee.com:howardlau/sysu-thesis-typst.git gh-pages |