ITS
Vue.js development
Introduction
GitHub is the playground for developers where they share their skills. However, automating deployment processes is essential; hence, GitHub Actions come into the picture. This tutorial will guide you through deploying your vue.js application using GitHub Pages with the help of GitHub Actions. Also, follow each step carefully to streamline your deployment workflow. Let’s delve into the tutorial guide of vue.js with GitHub actions for a successful project.
GitHub is a prominent cloud-based repository with over 100 million active users. To streamline the development project, GitHub introduced “GitHub Actions” in 2018 to automate and ease development workflow.
GitHub actions are the automated process allowing you to host, test, and deploy software. It is a crucial component of GitHub, which eases the development process with push and automation tasks. In simple terms, GitHub actions navigate the instructions you generate in your Git repository to automate the development process or an API for cause and effect.
Moreover, GitHub actions allow you to automate workflow based on specific events, such as push, creation actions, new releases, issues, etc. As a result, you can reuse, share, or modify your software development.
There are a few components of GitHub actions that you must know before starting your development workflow process.
1. Create a new GitHub repository, e.g., sample-project.
2. Push all your codes into this repository.
1. Create a .github Folder:
name: Deploy to Github Pages # Defines the name of the GitHub Actions workflow.
on:
push:
branches:
– develop # Triggers the workflow on each push to the ‘develop’ branch.
jobs:
build:
name: Build # Defines the name of the build job.
runs-on: ubuntu-latest # Specifies the operating system for the job.
steps:
– name: Checkout Repo # Checks out the repository.
uses: actions/checkout@v4
– name: Create Node Environment # Sets up Node.js environment.
uses: actions/setup-node@v4
with:
node-version: 16.x
– name: Install Packages and Build Application # Installs npm packages and builds the Vue.js application.
run: |
npm ci
npm run build
– name: Setup Pages # Configures pages for deployment.
id: pages
uses: actions/configure-pages@v3
– name: Build with Jekyll # Builds the application with Jekyll.
uses: actions/jekyll-build-pages@v1
with:
source: ./dist/
destination: ./_site
– name: Upload artifact # Uploads the build artifact.
uses: actions/upload-pages-artifact@v2
deploy:
name: Deploy Application # Defines the name of the deployment job.
# Add a dependency to the build job
needs: build # Specifies that the deployment job depends on the successful completion of the build job.
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # Grants write permission to deploy to Pages.
id-token: write # Grants write permission to verify the deployment source.
environment:
name: github-pages # Specifies the environment for deployment.
url: ${{ steps.deployment.outputs.page_url }} # Retrieves the deployment URL from the previous deployment step.
runs-on: ubuntu-latest # Specifies the operating system for the deployment job.
steps:
– name: Deploy to GitHub Pages # Deploys the application to GitHub Pages.
id: deployment
uses: actions/deploy-pages@v2 # Specifies the version of the deployment action.
It is essential because workflow often requires specific configurations based on particular actions and environments. To modify your Vue.config.js file, include the following code:
const { defineConfig } = require(‘@vue/cli-service’)
module.exports = defineConfig({
publicPath: ‘/sample-project/’ //you have to add your repo name here
})
We must perform the following steps to set up GitHub action and GitHub pages to perform our deployment process. Let’s find out how to test GitHub actions:
1. Commit and push the changes to the development branch.
2. Go to your GitHub repository’s settings.
After performing these steps, you can auto-deploy your project after each push. You can find an entire tutorial on GitHub Respiratory for more details.
With the following steps, you can successfully navigate the intricacies of automating the deployment of your Vue.js application on GitHub Pages using GitHub Actions. With the correct method, you can streamline development workflow and ease the developer’s task to hamper manual and repetitive tasks in your Vue.js with GitHub Actions.
Moreover, you will gain valuable insights into GitHub Pages, GitHub Actions, and Vue.js configurations. Now equipped with an automated deployment GitHub pipeline, you can easily showcase your Vue.js projects, fostering efficiency and agility in your development endeavors. However, if you are looking for a specialist who can streamline your project, get in touch with Vue.Js development company.