From 7855281b7fc2df4d0613b630f9698d0fc8386d67 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Wed, 12 Feb 2025 21:00:33 +0700 Subject: [PATCH] feat: deploy to github pages --- .github/workflows/github-pages.yml | 64 ++++++++++++++++++++++++++++++ meo-and-bin/src/router.js | 2 +- meo-and-bin/vite.config.js | 5 ++- 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/github-pages.yml diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml new file mode 100644 index 0000000..4db0fcc --- /dev/null +++ b/.github/workflows/github-pages.yml @@ -0,0 +1,64 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: + - master + pull_request: + branches: + - master + + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.17.0' + - name: Install dependencies + run: | + cd meo-and-bin + npm install + - name: Build project + run: | + cd meo-and-bin + npm run build + - name: Setup Pages + id: pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./meo-and-bin/dist + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/meo-and-bin/src/router.js b/meo-and-bin/src/router.js index ddd60e6..6d4aade 100644 --- a/meo-and-bin/src/router.js +++ b/meo-and-bin/src/router.js @@ -8,7 +8,7 @@ const routes = [ ] const router = createRouter({ - history: createWebHistory(), + history: createWebHistory(import.meta.env.BASE_URL), routes }) diff --git a/meo-and-bin/vite.config.js b/meo-and-bin/vite.config.js index 90ffbbf..8719ae9 100644 --- a/meo-and-bin/vite.config.js +++ b/meo-and-bin/vite.config.js @@ -24,5 +24,6 @@ export default defineConfig({ rewrite: (path) => path.replace(/^\/github-api/, '') } } - } -}) \ No newline at end of file + }, + base: process.env.NODE_ENV === "production" ? "/Valentine-Vue-Tailwind/" : "/", +})