ci: switch to static site deployment via Gitea Pages
Build and Deploy / build-and-deploy (push) Failing after 54s

- Replaced Docker image build/push with static site publishing using peaceiris/actions-gh-pages.
- Updated Vite configuration to use /lit-examples/ as the base path.
- Enhanced mpaHtmlPlugin to correctly prefix assets with the base path in subfolders.
- Updated CI permissions to allow content writing for deployment.
This commit is contained in:
2026-05-17 20:31:15 -07:00
parent b6d4d53b50
commit 22a1020d15
2 changed files with 13 additions and 34 deletions
+7 -30
View File
@@ -15,7 +15,7 @@ jobs:
build-and-deploy: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: write
packages: write packages: write
steps: steps:
@@ -43,34 +43,11 @@ jobs:
run: bazel build //... run: bazel build //...
- name: Build Site - name: Build Site
run: pnpm run build run: pnpm run build --base=/lit-examples/
- name: Set up Docker Buildx - name: Deploy Docs
uses: docker/setup-buildx-action@v3 uses: peaceiris/actions-gh-pages@v4
- name: Login to registry
uses: docker/login-action@v4
with: with:
registry: ${{ env.REGISTRY }} github_token: ${{ secrets.GITHUB_TOKEN }}
username: ${{ gitea.actor }} force_orphan: true
password: ${{ secrets.GIT_TOKEN }} publish_dir: dist
- name: Get image metadata
id: meta
run: |
NAME=$(node -p "require('./package.json').name.toLowerCase()")
OWNER=$(echo "${{ gitea.actor }}" | tr '[:upper:]' '[:lower:]')
echo "name=${NAME}" >> $GITHUB_OUTPUT
echo "owner=${OWNER}" >> $GITHUB_OUTPUT
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ steps.meta.outputs.owner }}/${{ steps.meta.outputs.name }}:latest
${{ env.REGISTRY }}/${{ steps.meta.outputs.owner }}/${{ steps.meta.outputs.name }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
+6 -4
View File
@@ -42,7 +42,7 @@ function getHtmlEntries() {
} }
// Vite plugin to rewrite HTML absolute assets to be subfolder-scoped // Vite plugin to rewrite HTML absolute assets to be subfolder-scoped
const mpaHtmlPlugin = () => { const mpaHtmlPlugin = (base = '/') => {
return { return {
name: 'mpa-html-plugin', name: 'mpa-html-plugin',
transformIndexHtml: { transformIndexHtml: {
@@ -53,7 +53,7 @@ const mpaHtmlPlugin = () => {
const subfolder = parts[0]; const subfolder = parts[0];
let transformed = html let transformed = html
// Rewrite absolute src/href paths like "/src/main.ts" to "/subfolder/src/main.ts" // Rewrite absolute src/href paths like "/src/main.ts" to "/base/subfolder/src/main.ts"
.replace(/(src|href)="\/([^"]+)"/g, (match, attr, path) => { .replace(/(src|href)="\/([^"]+)"/g, (match, attr, path) => {
if (path.startsWith('http://') || path.startsWith('https://')) { if (path.startsWith('http://') || path.startsWith('https://')) {
return match; return match;
@@ -61,7 +61,8 @@ const mpaHtmlPlugin = () => {
if (path.startsWith(subfolder)) { if (path.startsWith(subfolder)) {
return match; return match;
} }
return `${attr}="/${subfolder}/${path}"`; const prefix = base === '/' ? '' : base.replace(/\/$/, '');
return `${attr}="${prefix}/${subfolder}/${path}"`;
}); });
// Clean up platform-specific non-module scripts like capacitor.js which fail Vite build // Clean up platform-specific non-module scripts like capacitor.js which fail Vite build
@@ -156,7 +157,8 @@ const externalizeMissingPlugin = () => {
}; };
export default defineConfig({ export default defineConfig({
plugins: [mpaHtmlPlugin(), tsResolvePlugin(), externalizeMissingPlugin()], base: '/lit-examples/',
plugins: [mpaHtmlPlugin('/lit-examples/'), tsResolvePlugin(), externalizeMissingPlugin()],
resolve: { resolve: {
alias: { alias: {
'lit/decorators': 'lit/decorators.js', 'lit/decorators': 'lit/decorators.js',