The PacManBlazor project incorporates Continuous Integration and Continuous Deployment (CI/CD) automation through a series of GitHub Actions workflows. Below is a detailed explanation of how CI/CD is automated in this project, including the relevant scripts and their configurations.
GitHub Actions Workflows
The project contains multiple workflows located in the .github/workflows/
directory. The key workflows relevant for CI/CD automation are as follows:
- Build and Test Workflow:
build-and-test.yml
- Build, Deploy, and Publish Workflow:
build-deploy-publish.yml
- Deploy to GitHub Pages Workflow:
deploy-to-github-pages.yml
1. Build and Test Workflow
File: .github/workflows/build-and-test.yml
This workflow is triggered on pull requests and pushes to the main branch to ensure code quality through building and testing the application.
Example Configuration:
name: Build and Test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release
- name: Run Tests
run: dotnet test --no-build --verbosity normal
2. Build, Deploy, and Publish Workflow
File: .github/workflows/build-deploy-publish.yml
This workflow handles the building and deploying of the application after ensuring that tests have passed.
Example Configuration:
name: Build, Deploy, and Publish
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release
- name: Publish
run: dotnet publish --configuration Release --output ./publish
- name: Deploy to GitHub Pages
uses: JamesIves/[email protected]
with:
folder: ./publish
3. Deploy to GitHub Pages Workflow
File: .github/workflows/deploy-to-github-pages.yml
This workflow triggers deployment to GitHub Pages, packaging the built application for public access.
Example Configuration:
name: Deploy to GitHub Pages
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build
run: dotnet build --configuration Release
- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ./publish
Summary
The CI/CD automation for the PacManBlazor project is effectively achieved using GitHub Actions through three primary workflows. The build-and-test.yml
ensures code quality by running builds and tests, while build-deploy-publish.yml
automates the process of publishing the application after a successful build. Finally, deploy-to-github-pages.yml
handles the deployment to GitHub Pages, ensuring that the latest version of the application is always live.
By following the structure and examples provided within these scripts, developers can efficiently manage their CI/CD processes in projects leveraging similar frameworks and tools.