Skip to content

Commit

Permalink
feat: Add GitHub Pages deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
takeshi-hirosue committed May 19, 2024
1 parent fb39eea commit 71ba34c
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# 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

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4

- name: Install dependencies
run: npm install

- name: Install Rollup
run: npm install @rollup/rollup-linux-x64-gnu --save-optional

- name: Build project
run: npm run build

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: './build/client/'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# templates/spa

[![Deploy to GitHub Pages](https://github.com/Thirosue/remix-spa-shadcn-dashboard-sample/actions/workflows/deploy.yml/badge.svg)](https://github.com/Thirosue/remix-spa-shadcn-dashboard-sample/actions/workflows/deploy.yml)

This template leverages [Remix SPA Mode](https://remix.run/docs/en/main/guides/spa-mode) and the [Remix Vite Plugin](https://remix.run/docs/en/main/guides/vite) to build your app as a Single-Page Application using [Client Data](https://remix.run/docs/en/main/guides/client-data) for all of your data loads and mutations.

## Setup
Expand Down
14 changes: 14 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { copyFileSync } from "node:fs";
import { join } from "node:path";

export default defineConfig({
// https://zenn.dev/cybozu_frontend/articles/remix-spa-mode-gh-page
base: "/remix-spa-shadcn-dashboard-sample/", // for GitHub Pages Deployment
plugins: [
remix({
ssr: false,
basename: "/remix-spa-shadcn-dashboard-sample/", // for GitHub Pages Deployment
buildEnd(args) {
// for GitHub Pages Deployment
if (!args.viteConfig.isProduction) return;
const buildPath = args.viteConfig.build.outDir;
copyFileSync(
join(buildPath, "index.html"),
join(buildPath, "404.html"),
);
},
}),
tsconfigPaths(),
],
Expand Down

0 comments on commit 71ba34c

Please sign in to comment.