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: Build with Trunk and Deploy with GitHub Pages | |
# By default, runs if you push to master. keeps your deployed app in sync with master branch. | |
on: | |
push: | |
branches: | |
- main | |
- 'cicd/**' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# to only run when you do a new github release, comment out above part and uncomment the below trigger. | |
# on: | |
# release: | |
# types: | |
# - published | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
build-github-pages: | |
environment: | |
name: Build with Trunk and Deploy with GitHub's "static" Starter Workflow | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 # repo checkout | |
- uses: actions-rs/toolchain@v1 # get rust toolchain for wasm | |
with: | |
profile: minimal | |
toolchain: stable | |
target: wasm32-unknown-unknown | |
override: true | |
- name: Download and install Trunk binary | |
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-; | |
# Install Trunk in (app dir) `/home/runner/work/folsum/folsum/folsum/` because `trunk` doesn't have a path parameter. | |
working-directory: folsum | |
- name: Read subdomain from CNAME file | |
id: get_cname | |
run: | | |
pwd | |
ls | |
if [ -f CNAME ]; then | |
SUBDOMAIN=$(cat folsum/assets/CNAME) | |
echo "subdomain=$SUBDOMAIN" >> "$GITHUB_OUTPUT" | |
else | |
echo "no cname file found." | |
fi | |
- name: Rust Cache # cache the rust build artifacts | |
uses: Swatinem/rust-cache@v1 | |
- name: Build # build | |
# "${GITHUB_REPOSITORY#*/}" evaluates into the name of the repository | |
# using --public-url something will allow trunk to modify all the href paths like from favicon.ico to repo_name/favicon.ico . | |
# this is necessary for github pages where the site is deployed to username.github.io/repo_name and all files must be requested | |
# relatively as eframe_template/favicon.ico. if we skip public-url option, the href paths will instead request username.github.io/favicon.ico which | |
# will obviously return error 404 not found. | |
# Create webfiles in `/home/runner/work/folsum/folsum/folsum/dist/`. | |
run: ./trunk build --release --public-url ${{ steps.get_cname.outputs.subdomain }}; | |
# Run build command in (app dir) `/home/runner/work/folsum/folsum/folsum/` because `trunk` doesn't have a path parameter. | |
working-directory: folsum | |
# Deploy static files with GitHub's "static" starter workflow. https://github.com/actions/starter-workflows/blob/main/pages/static.yml | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
# Upload contents of Zola's output directory. | |
path: 'folsum/dist/' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |