Skip to content

aaaa

aaaa #23

name: publish to github pages
on:
push:
# Trigger when there is a new commit on main branch
branches: [ main ]
# also trigger when a new release tag is added to the repo
tags:
- "v*"
# Cancel already running jobs
concurrency:
group: publish_to_pages_${{ github.head_ref }}
cancel-in-progress: true
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
strategy:
matrix:
include:
- name: Publish website to Github Pages
runner: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.setup_pages.outputs.base_url }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Build website
run: cargo run -p website
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload pages
uses: actions/upload-pages-artifact@v3
with:
path: 'website/root'
- name: Create GitHub Pages Deployment
id: deployment
uses: actions/github-script@v7
with:
script: |
// Get the artifact ID from the upload step
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
});
const artifact = artifacts.data.artifacts.find(
artifact => artifact.name === 'github-pages'
);
if (!artifact) {
throw new Error('GitHub Pages artifact not found');
}
// Create the Pages deployment
const deployment = await github.rest.repos.createPagesDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
pages_build_version: 'latest',
oidc_token: process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN,
preview: false
});
console.log('Deployment created:', deployment.data);
core.setOutput('page_url', `https://${context.repo.owner}.github.io/${context.repo.repo}/`);
return deployment.data;