- The main concepts attributed to CI/CD are continuous integration, continuous delivery, and continuous deployment.
- CI => Continuous Integration
- CD => Continuous Delivery & Deployment
- To add CI/CD pipeline to your project, create a
.github/workflows/
folder at the root of the project. - Create
BuildAndDeploy.yml
file in./.github/workflows
- Paste next code in the
BuildAndDeploy.yml
name: Build and Deploy
on: [push]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
run: |
npm install
npm run build
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: build # The folder the action should deploy.
The part on: [push]
means, when you push your code changes next time, GitHub will run these jobs in actions. If these jobs succeed, this script create a new branch gh-pages
in your project repository, and deploy your build to GitHub pages.
gh-pages
branch is build version of your project.- Your project page is available in
https://[YourGitHubName].github.io/[YourRepositoryName]
- In
package.json
file, add a new line to the beginning of the object and add"homepage": ".",
to it.
- When you push code changes first time, with this yml file, it can take up to hours before your gh pages are available.
- If your repository name contains hyphen or possibly other special characters, your gh-pages will not work.