Hey everyone, Welcome back! This blog forms the 9th part of our Microservices in Go series. We have built a CI pipeline & have also manually created a CD pipeline in our previous blogs. Now, we will automate our CD (Continuous Deployment) in this blog.
Continuous Deployment
As defined by Google, Continuous Deployment (CD) is a software release process that uses automated testing to validate if changes to a codebase are correct and stable for immediate autonomous deployment to a production environment.

To be concise, it’s all about making sure our latest codebase is stable, and deploying it to our production environment in an automated fashion.
CD using GitHub Actions and ACR
In our previous blogs, we used GitHub actions to create Docker image of our codebase on every push happening to master branch. Then, we have seen how to deploy our App on Azure using Azure Container Registry & Azure App services.
Now, we will use GitHub Actions to push our already built docker image into ACR on every push.
Configuring GitHub Secrets
As we need to push our image to our private container registry on Azure, we need to make sure our credentials are available for the workflow to run. But, making them part of workflow will expose our creds 😟.
No worries, GitHub has got our back! We can configure our secrets in a safe environment and use them during workflow. Open you repository settings, Settings-> Secrets-> Actions.

Configure ACR_PASSWORD & ACR_USERNAME in the environment with the creds available on Azure at Container Registry -> Access keys.

Creating a Workflow
Now, go ahead and modify our existing workflow file with the below contents:
name: Build Docker Image.
# Trigger workflow on push to master branch
on:
push:
branches: [ master ]
jobs:
build:
name: Build & Push Docker Image.
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Azure Container Registry Login
uses: azure/docker-login@v1
with:
login-server: helloworldblog.azurecr.io
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Build Docker Image
run: docker build -t helloworldblog.azurecr.io/microservice:latest .
- name: Push Docker Image to ACR
run: docker push helloworldblog.azurecr.io/microservice:latest
In our above workflow, we have configured 4 steps as part of our workflow.
- Checkout Codebase
- Login to ACR using Creds configured in GitHub secrets.
- Build Docker Image from our codebase.
- Push Docker Image to Azure Container Registry.
Now, let’s make a push to master, and check if CD pipeline is being triggered and also check if the image is being pushed to ACR, from where our App service pulls the image.
New Commit

Now, this should trigger CI & CD pipeline defined in our GitHub workflows.

Let’s check ACR if an image is pushed.

Huhooo! We did it. Our Microservice is now well established with a CI & CD pipeline.

Only missing piece is that, we are referring to a local JSON file for data, let’s make it a database in our upcoming blog, which would be the end of this great tour of learning Microservices in Go ❤️. Until then, stay safe. Cheers ✌️
2 responses to “Part – IX: Push to ACR using GitHub Actions (Continuous Deployment)”
Awesome post mate. This really helped me a lot. keep it up.
LikeLike
Glad it helped. This motivates me to write more of such one’s 🙂
LikeLike