diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 0000000..048ae7d --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,39 @@ +name: Build & Deploy + +on: + push: + branches: ["main"] + +jobs: + deploy: + runs-on: ubuntu-latest + + permissions: + contents: write + + strategy: + matrix: + node-version: ["20.9.0"] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + + - name: Install packages + run: npm i + + - name: Run npm build + run: npm run build + + - name: Deploy to gh-pages + uses: peaceiris/actions-gh-pages@v3 + with: + publish_dir: dist + publish_branch: gh-pages + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 03df0c3..9611f18 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,11 +2,12 @@ import path from "path" import react from "@vitejs/plugin-react" import { defineConfig } from "vite" -export default defineConfig({ +export default defineConfig(({ command }) => ({ + base: command === 'serve' ? '/' : '/shadcn-sample/', plugins: [react()], resolve: { alias: { "@": path.resolve(__dirname, "./src"), }, }, -}) \ No newline at end of file +})) \ No newline at end of file