An open API service indexing awesome lists of open source software.

https://github.com/basemax/vuejs-cicd-deploy-on-github-pages

This project demonstrates how to set up a Vue 3 + Vite project using Bun or Node.js, with automated deployment to GitHub Pages using gh-pages package and GitHub Actions.
https://github.com/basemax/vuejs-cicd-deploy-on-github-pages

bun cd ci ci-cd cicd deploy github github-action github-actions vite vue vuejs

Last synced: 2 months ago
JSON representation

This project demonstrates how to set up a Vue 3 + Vite project using Bun or Node.js, with automated deployment to GitHub Pages using gh-pages package and GitHub Actions.

Awesome Lists containing this project

README

          

# ๐Ÿš€ Vue.js CI/CD Deployment on GitHub Pages (via Node)

This project demonstrates how to set up a **Vue 3 + Vite** project using **Bun** or **Node.js**, with automated deployment to **GitHub Pages** using gh-pages package and GitHub Actions.

> ๐Ÿ“ก **Live Demo:** [https://BaseMax.github.io/vuejs-cicd-deploy-on-github-pages](https://BaseMax.github.io/vuejs-cicd-deploy-on-github-pages)

---

## ๐Ÿ“ฆ Tech Stack

- โšก [Vue 3](https://vuejs.org/)
- โš—๏ธ [Vite](https://vitejs.dev/)
- ๐Ÿงช [Bun](https://bun.sh/) or [Node.js](https://nodejs.org/)
- ๐ŸŒ€ GitHub Pages deploy script
- ๐Ÿ›  GitHub Actions CI/CD

---

## ๐Ÿงช Development

Run locally with **Bun**:

```bash
bun install
bun run dev
```

Or with npm:

```bash
npm install
npm run dev
```

## ๐Ÿš€ Deployment

This project uses a custom Node.js script to deploy the built app to the `gh-pages` branch.

## โ–ถ Manual Deploy

```bash
npm run deploy
```

This runs deploy-gh-pages.mjs which:

- Builds the project using vite build
- Creates an orphan gh-pages branch
- Commits the `dist/` folder
- Force-pushes it to GitHub
- Cleans up local state

## โ–ถ GitHub Actions CI/CD

Automatic deployment is also set up via .github/workflows/deploy.yml. On every push to main, it:

- Installs dependencies
- Runs the deploy script (npm run deploy)
- No manual steps are needed after a push to main.

## ๐Ÿ“ Directory Structure

```bash
.
โ”œโ”€โ”€ .github/workflows/deploy.yml # GitHub Actions CI/CD
โ”œโ”€โ”€ src/ # Vue app source code
โ”œโ”€โ”€ dist/ # Auto-generated after build
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ vite.config.ts
โ””โ”€โ”€ package.json
```

## ๐Ÿ›  Scripts in package.json

For your local machine:

```json
{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"deploy": "vite build && gh-pages -d dist"
}
}
```

For GitHub Actions:

```json
{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"deploy": "vite build && gh-pages -d dist -u 'Max Base (Seyyed Ali Mohammadiyeh) ' -r https://x-access-token:${GITHUB_TOKEN}@github.com/BaseMax/vuejs-cicd-deploy-on-github-pages.git"
}
}
```

## ๐Ÿ” Notes

Make sure GitHub Pages is enabled in repo settings:

- Branch: `gh-pages`
- Folder: `/` (root)

This repo is set to private: `"private": true` (optional for public sharing)

You need write access for pushing to `gh-pages`.

## ๐Ÿ‘ค Author

Seyyed Ali Mohammadiyeh (Max Base)

๐Ÿ“ฌ maxbasecode@gmail.com

๐Ÿ”— https://github.com/BaseMax

## ๐Ÿชช License

MIT