Continuous Integration (CI) is a development practice where developers frequently merge their code changes into a central repository. Each merge triggers an automated build and test process. The primary goals of CI are to:
- Detect integration issues early: Catch conflicts and bugs quickly, reducing the effort required to fix them.
- Improve code quality: Enforce coding standards and run automated tests on every change.
- Produce releasable artifacts: Generate deployable software versions (e.g., Docker images) after successful validation.
To begin, fork this repository to your own GitHub account. This will create a copy of the project under your personal namespace, allowing you to make changes and set up GitHub Actions without affecting the original repository.
- Go to the original repository's page on GitHub.
- Click the "Fork" button in the top right corner.
Once forked, clone your forked repository to your local machine:
git clone [https://github.com/your-username/your-forked-repository.git](https://github.com/your-username/your-forked-repository.git) # Replace with your actual forked repo URL
cd your-forked-repository/week07 # Adjust path as needed for Week 07
Your GitHub Actions workflow will need credentials to interact with Azure and ACR. Create these as secrets in your GitHub repository:
- Go to your GitHub repository.
- Navigate to Settings > Secrets and variables > Actions.
- Click New repository secret.
-
AZURE_CREDENTIALS
: This JSON object allows GitHub Actions to authenticate with Azure. To create the necessary Azure Service Principal, follow the official Microsoft Learn documentation: How to create a service principal for an Azure application using the portalOnce you have created the Service Principal, you will find the required values for
clientId
,clientSecret
,subscriptionId
, andtenantId
. Use these to construct the JSON secret:{ "clientId": "<Client ID>", "clientSecret": "<Client Secret>", "subscriptionId": "<Subscription ID>", "tenantId": "<Tenant ID>" }
Paste this complete JSON object as the value for the
AZURE_CREDENTIALS
secret.-
ACR_LOGIN_SERVER
: The full login server name of your Azure Container Registry (e.g.,myacr.azurecr.io
).You can find this by navigating to your Azure Container Registry in the Azure portal, selecting "Access keys" under "Settings", and locating the "Login server" value. Add this value as the
ACR_LOGIN_SERVER
secret.
-
The CI pipeline is configured to trigger automatically in the following scenarios:
-
On
push
to themain
branch: Any code changes merged into themain
branch will start the CI workflow. -
On changes to
backend/\*\*
paths: The pipeline is optimized to run only when relevant backend code or the workflow file itself changes. -
Manually via
workflow_dispatch
: You can trigger the workflow manually from the GitHub Actions tab in your repository. Go to the "Actions" tab, select "Backend CI - Test, Build and Push Images to ACR" from the workflows list, and click "Run workflow".
After triggering the pipeline, you can monitor its progress and results:
-
Navigate to the Actions tab: In your GitHub repository, click on the "Actions" tab.
-
Select the "Backend CI - Test, Build and Push Images to ACR" workflow: You will see a list of workflow runs. Click on the latest run.
-
Review job progress: You can see the
test_and_lint_backends
andbuild_and_push_images
jobs executing. -
Inspect logs: Click on any step within a job to view its detailed logs, including test results, linting output, and Docker build/push messages.
-
Successful completion: A green checkmark next to the workflow run indicates all jobs passed successfully, meaning your code is tested, linted, and images are pushed to ACR.