In this example, we extend the application from Week 06 – Example 01 by introducing a Continuous Integration (CI) pipeline using GitHub Actions.
The CI pipeline will:
- Run automated tests for all backend services.
- Continue only if all tests pass.
- Build Docker images for all backend services and the frontend.
- Authenticate with Microsoft Azure.
- Push the Docker images to Azure Container Registry (ACR).
Log into GitHub, then go to this weeks repository https://github.com/sit722-devops/week07 and Fork this into your account.
After forking the repository, clone your fork to your local machine.
git clone <YOUR-FORKED-REPOSITORY-URL>Navigate to the project directory.
cd <PROJECT-DIRECTORY>Make sure the Azure Container Registry has been successfully created before configuring the CI pipeline.
GitHub Actions requires permission to authenticate with Azure and push Docker images to Azure Container Registry.
Create a Microsoft Entra application and service principal by following the official Microsoft documentation:
https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal
When creating the service principal, make sure you record the following values:
- Application (Client) ID
- Directory (Tenant) ID
- Client Secret Value
- Azure Subscription ID
Important: Copy the Client Secret Value when it is created. The secret value is displayed only once.
The service principal must have permission to push Docker images to Azure Container Registry.
In the Azure Portal:
- Open your Azure Container Registry.
- Go to Access control (IAM).
- Select Add role assignment.
- Assign the appropriate role that allows the service principal to push images to the registry (i.e.,
Contributor). - Select the service principal created in the previous step.
- Complete the role assignment.
Open your GitHub repository and go to:
Settings → Secrets and variables → Actions → Secrets
Create the following Repository Secret:
AZURE_CREDENTIALS
Use the following structure:
{
"clientId": "YOUR_CLIENT_ID",
"clientSecret": "YOUR_CLIENT_SECRET",
"subscriptionId": "YOUR_SUBSCRIPTION_ID",
"tenantId": "YOUR_TENANT_ID"
}Replace each value with the information from your Azure service principal and subscription.
Never commit Azure credentials or client secrets to the GitHub repository.
Go to:
Settings → Secrets and variables → Actions → Variables
Create the following Repository Variables:
ACR_NAME
Set the value to the name of your Azure Container Registry.
Create another variable:
ACR_LOGIN_SERVER
Set the value to the login server of your Azure Container Registry.
Run the workflow manually from the Actions section of the GitHub repository.
Alteernatively, Make some changes in code and push the changes.
Monitor the workflow and confirm that all backend tests pass before the Docker image build and push jobs begin.
After the CI pipeline completes successfully:
- Open the Azure Portal.
- Open your Azure Container Registry.
- Select Repositories.
- Verify that all application Docker images have been pushed successfully.
The CI pipeline is complete when all tests pass and all required Docker images are available in ACR.
Delete all Azure resources created for this example after completing the practical.
