From a3b2a29e5bb1713560156282b101dc7264657351 Mon Sep 17 00:00:00 2001 From: Helen Chong <119173961+helenclx@users.noreply.github.com> Date: Sun, 2 Jun 2024 15:24:14 +0800 Subject: [PATCH] Set up GitHub action to deploy to GitHub Pages --- .github/workflows/gh-pages.yml | 63 ++++++++++++++++++++++++++ 1-digital-business-card/vite.config.js | 4 ++ 2-travel-journal/vite.config.js | 4 ++ 3-quizzical/vite.config.js | 4 ++ 4 files changed, 75 insertions(+) create mode 100644 .github/workflows/gh-pages.yml diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 0000000..b79ca73 --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,63 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: ["main"] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: latest + + # digital-business-card project + - name: Build digital-business-card + run: | + cd 1-digital-business-card + npm install && npm run build + cd .. + mkdir -p deploy/1-digital-business-card + cp -r 1-digital-business-card/build/* deploy/1-digital-business-card/ + + # travel-journal project + - name: Build travel-journal + run: | + cd 2-travel-journal + npm install && npm run build + cd .. + mkdir -p deploy/2-travel-journal + cp -r 2-travel-journal/build/* deploy/2-travel-journal/ + + # quizzical project + - name: Build quizzical + run: | + cd 3-quizzical + npm install && npm run build + cd .. + mkdir -p deploy/3-quizzical + cp -r 3-quizzical/build/* deploy/3-quizzical/ + + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: "./deploy" + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/1-digital-business-card/vite.config.js b/1-digital-business-card/vite.config.js index 5a33944..d520e5e 100644 --- a/1-digital-business-card/vite.config.js +++ b/1-digital-business-card/vite.config.js @@ -4,4 +4,8 @@ import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], + build: { + outDir: "dist", + }, + base: "", }) diff --git a/2-travel-journal/vite.config.js b/2-travel-journal/vite.config.js index 5a33944..d520e5e 100644 --- a/2-travel-journal/vite.config.js +++ b/2-travel-journal/vite.config.js @@ -4,4 +4,8 @@ import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], + build: { + outDir: "dist", + }, + base: "", }) diff --git a/3-quizzical/vite.config.js b/3-quizzical/vite.config.js index 5a33944..d520e5e 100644 --- a/3-quizzical/vite.config.js +++ b/3-quizzical/vite.config.js @@ -4,4 +4,8 @@ import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], + build: { + outDir: "dist", + }, + base: "", })