10 days ago I published an article how we integrate Reliza Hub with GitHub Actions and ArgoCD for continuous delivery to Kubernetes. Today I am going to improve the approach described there with a new feature we just added to Reliza Hub. The feature is on-demand builds for GitHub Actions that would run on new releases and approvals.
As with the original article we will be discussing Continuous Integration and Continuous Deployment for the Mafia Game project. By the way, if you want to play Classic Mafia with me, I’m usually playing every Saturday with Vancouver Mafia Club.
So the point we want to improve from the original article is the GitHub Actions workflow to poll Reliza Hub for new production versions. This workflow was running on a cron every 5 minutes and if there was a new version, it would roll out an update. The improvement we want to make – instead of using cron there, we want to have on demand GitHub Actions run every time someone approves a Mafia Game product release. Below I will show step-by-step guide how to achieve that.
GitHub Actions Side
In the GitHub, proceed to Reliza Hub app at https://github.com/apps/reliza-hub.
Click Configure. Then choose your user or organization where you want to install the application.
In my case, I will be selecting my user taleodor and only one repository – taleodor/mafia-deployment – where my GitHub Actions workflows are deployed.
Now I just click Install which brings me to the App Installation page shown below.
One thing we need to do here is note the installation id which is shown in the browser address bar. In my case that is 1234567 as shown on the image above. Kidding – I’ve hidden the real id, but you get the idea 🙂 .
We are now done with GitHub part and moving on to modify our workflow code to listen to trigger build events from Reliza.
GitHub Actions Workflow Code Side
Remember that we had cron doing updates which had this code at the top:
on:
schedule:
- cron: '*/5 * * * *'
Meaning that our action would be running every 5 minutes.
All we need to do here is change it to action listening code as following:
on:
repository_dispatch:
types: [reliza-build-event]
This is all we needed to do in the workflow code side, and now we are moving to the Reliza Hub SaaS side.
Reliza Hub SaaS Side
First of all we need to ensure that we already have integrated repository registered on Reliza Hub. This is indeed the case for the Mafia Game project, but if not, we need to go to VCS menu and click on the plus-circle icon to add it there.
Now after we ensured we have our repository, remember that our Mafia Game project consists of 2 major parts: UI and back-end. Each of them should trigger deployment build on approval. So we need to add integration to each of those projects. I will demonstrate what needs to be done on the mafia-vue (UI) project. Doing so for the back-end would be essentially the same – so I will save some space by not mentioning it explicitly.
First we need to go to our project section and click on the tool icon to open Project Settings as shown below.
Then in the GitHub App Installation Id we enter our Installation Id from GitHub noted above. We also set checkbox called Trigger GitHub Action On Approval. Note that when this checkbox is checked, every new release for the project and every following approval will trigger build on GitHub Actions.
Finally we click edit icon near Not Set and select our VCS Repository. How it all looks is shown below.
I then click Save GitHub Integration button. And then click Trigger GitHub Build to see if our integration works as expected. If everything was configured correctly, you would see GitHub Actions build started by reliza-hub bot with the event called reliza-build-event in your GitHub Actions build page as shown below.
How it Works on Releases and Approvals End-to-End
Now, when everything is configured let us push a simple change to the Mafia Project. In this case, I want to add a short page about classic mafia clubs. I prepare my change and push it to the UI repository.
CI process using GitHub Actions in Mafia Vue repository picks up the change and starts the build.
When it is done, I am getting slack notification that the build is ready.
Following that our new GitHub Actions integration will trigger deployment build. This deployment build will pull up new project definition for testmafia.brolia.com server and commit it to the mafia-deployment project. This will in turn trigger new deployment for testmafia itself via ArgoCD. Finally, new Mafia product will be created. I will get notified of all that activity via slack:
Now, I would test the changes in testmafia.brolia.com and once happy set approval to my Product release.
Setting approvals triggers another build on GitHub Actions, which would this time promote our new release to the mafia.brolia.com production instance. Here is how it looks on Reliza Hub after the update:
Summary
We were able to replace deployment job working on cron schedule to on-demand version which is triggered by new releases and approvals. All that by extending GitHub Actions functionality with on-demand builds using new Reliza Hub integration capabilities.
Note that current integration is static in terms that it does not send any special parameters to GitHub Actions.
I am now thinking about creating a service with parametrized on-demand builds on GitHub Actions managed from Reliza Hub. You would be able to send custom parameters from there to GitHub Actions builds and trigger them. Would it be useful for you?
2 comments
Comments are closed.