WebApiCICDWorkFlow
is a demonstration project built with .NET Core, showcasing the fundamentals of Continuous Integration and Continuous Deployment (CI/CD) for a Web API. This project is ideal for developers looking to understand or implement basic CI/CD practices in their .NET Core applications.
- Program.cs: The entry point for the Web API application.
- Calculator: A class library implementing basic arithmetic operations (add, subtract, multiply, divide).
- DiceRolling: A class simulating dice rolls, demonstrating random number generation.
- MSTest: Integration for unit testing, ensuring code reliability and quality.
- CI/CD Workflows: Includes GitHub Actions workflows for pull requests, labeling, and publishing to Azure Web Apps.
- Code Quality: Integrated with DeepSource for automated code analysis, ensuring adherence to best practices and coding standards.
- Pull Request Template: A predefined template for pull requests to streamline contributions and code reviews.
To get a local copy up and running, follow these simple steps.
- .NET Core SDK
- An Azure account (for deployment)
- Clone the repo
git clone https://github.com/Andronovo-bit/WebApiCICDWorkFlow.git
- Navigate to the project directory
cd WebApiCICDWorkFlow
- Restore dependencies
dotnet restore
- Run the application
dotnet run
- Pull Request Workflow (
pull_request.yaml
): Automates testing and code quality checks upon pull request submissions. - PR Labeler (
pr-labeler.yml
): Automatically labels pull requests based on the content and paths affected. - Publish Workflow (
publish.yml
): Handles the deployment of the application to Azure Web Apps upon merging to the main branch. - Labeler Workflow (
labeler.yml
): Automatically labels issues and pull requests based on defined criteria. - Semantic Versioning (
semantic.yml
): Enforces semantic versioning rules for commits and pull request merges. - DeepSource Integration: Performs automated code analysis to identify issues and ensure code quality.
- Sign in to the Azure Portal.
- From the Azure portal menu, select "Create a resource".
- In the "Search the Marketplace" field, type 'Web App' and press enter.
- Select "Web App" from the results, then click "Create".
- Fill in the details for your web app, such as Subscription, Resource Group, Name, Publish (Code), and Runtime Stack (.NET Core).
- Click "Review + create" and then "Create" after verifying your details.
- Navigate to your GitHub repository.
- Go to "Settings" > "Secrets" > "Actions".
- Click on "New repository secret".
- Add the following secrets required for Azure deployment:
AZURE_PUBLISH_PROFILE
: The publish profile XML content. (You can download this from your Azure Web App's "Deployment Center".)
- Use these secrets in your
publish.yml
GitHub Action workflow to deploy your application.
- Go to the Semantic Pull Requests app page on GitHub Marketplace.
- Click "Install it for free" > "Complete order and begin installation".
- Select the repository where you want to add the Semantic Pull Requests app.
- After installation, the app will automatically check if your pull requests follow semantic versioning guidelines.
- Visit DeepSource and sign up for an account. You can sign up using your GitHub account for easier integration.
- Once signed up, you'll be prompted to add a new repository.
- In the DeepSource dashboard, click on "Add repository".
- Select your GitHub repository from the list.
- DeepSource will provide a
.deepsource.toml
configuration file. Add this file to your repository to specify analysis settings. - Activate analysis on your repository. DeepSource will now analyze your code on each commit and pull request.
By following these additional steps, you'll enhance your project with automated deployments, enforced semantic versioning, and continuous code quality checks.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.