The blog for Design Patterns, Linux, HA and Myself!
Now, you can create your CI/CD pipelines for your Github repositories using Github Workflows.
However, there were some services like, Travis-CI, already available for the CI/CD needs but for the private repositories it was a dire need.
The setup requires:
The runner can have the following labels:
In this tutorial we’ll be using a self hosted runner and it is divided into the following sections:
Go to your repository’s settings:
Click on the Actions menu option:
Click on the button Add Runner:
You’ll be presented with a list of action items:
Once you’ve completed all the tasks in the configured section, the runner will be available on the same page:
Well, a better way would be setup the runner as a service instead of running as a bash script. It can installed using the following command:
sudo ./svc.sh install
To start the service, execute the following command:
sudo ./svc.sh start
You can check the status of the service using the following command:
sudo ./svc.sh status
However, it is not required right now but you stop and unistall this service using the following commads:
sudo ./svc.sh stop
sudo ./svc.sh uninstall
mkdir -p .github/workflows
touch .github/workflows/codiwan-test.yml
Actions
section in the Github Page.
name: Codiwan Test Deploy
name: Codiwan Test Deploy
on:
push:
branches:
- master
name: Codiwan Test Deploy
on:
push:
branches:
- master
jobs:
test-deploy-job:
name: Test and Deploy Job
runs-on: self-hosted
steps:
- uses: actions/checkout@master
- run: /usr/local/bin/hugo
Here the there’s a single job whose job is to test and deploy.
- uses: actions/checkout@master
.runs-on
.
runs-on: self-hosted
Hugo
. Surely, your require would be different.
run: /usr/local/bin/hugo
name: Codiwan Test Deploy
on:
push:
branches:
- master
jobs:
test-deploy-job:
name: Test and Deploy Job
runs-on: self-hosted
steps:
- uses: actions/checkout@master
- name: Check Hugo
run: /usr/local/bin/hugo
if: success()
- name: Check permissions
if: success()
run: chmod +x make_it_live.sh
- name: Make it Live
if: success()
run: ./make_it_live.sh
if: success()
. This makes sure that the current step runs only if the previous step
executed successfully. It makes the job sequential.make_it_live.sh
, to update the Nginx root directory.run: chmod +x make_it_live.sh
run: ./make_it_live.sh
So, we’ve created a very simple pipeline now. Let’s test it by committing this file to the master
branch.
Once pushed, the workflow will start. Go to the Actions
page for checking it’s status.
The status of the jobs are presented in the section that have the same name as the Job. In our case it is Test and Deploy Job
.
Some links that can provide you more detail: