Skip to content

Instantly share code, notes, and snippets.

@kom50
Last active July 13, 2024 12:50
Show Gist options
  • Save kom50/362b4d9e714f08465a91970b7aa7aa21 to your computer and use it in GitHub Desktop.
Save kom50/362b4d9e714f08465a91970b7aa7aa21 to your computer and use it in GitHub Desktop.
Deploy Your Vite/Vue 3 Application in GitHub Pages using GitHub Actions

Deploy Your Vite/Vue 3 Application in GitHub Pages using GitHub Actions

  • Copy the deploy.yml file contents
  • And create deploy.yml file in .github/workflows folder inside your repo

Change workflow permissions

  • Go to the repo settings
  • Then perform following steps that are given in images
  • And lastly, select Read and write permissions and hit Save:

repo settings

workflow permissions 1

Note - Basically, our action is going to modify the repo, so it needs the write permission.

Create GitHub token for GitHub Actions

A/c to our requirements generates a GitHub token and add to in Repository secrets

To perform following steps

Actions secrets and variables

name: Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run Git commands
run: |
git config --global user.email "your email"
git config --global user.name "your github username"
# Install depedencies
npm i
# build
npm run build
echo 'Deploying to gh-pages...'
git add dist -f
git commit -m 'Deploy'
git push origin `git subtree split --prefix dist main`:gh-pages --force
echo 'Done'
env:
github-token: ${{ secrets.GH_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment