GitHub pipelines

A github(or any other git implementation pipeline) ensures that code is run automaticly as an update to the repository occurs. To automate this within github there are a few conditions that have to be met:

See for the documentation:

Github self hosted runner

  • A github self hosted runner is configured
  • The runner has to be availlable for the group/project
  • The repository has a pipeline configured

.github/workflows

Tasks to be executed in a pipeline are specified in a file called ".github/workflows".
In this file are the conditions when and how to run the code in that pipeline on any momment in the development process.
A pipeline is triggered on ANY update to the registry. Depending on the contents of the .github/workflows, code will be executed, or not.

There is good documentation about github workflows availlable online:

GitHub workflows

An example:

jobs:
  lint:
    container: image-registry:5000/rh-python-image:latest

    if: contains( github.ref, 'dev')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - run: ansible-lint

 deploy:
    container: image-registry:5000/rh-python-image:latest

    if: contains( github.ref, 'master')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - run: ansible-playbook main.yml -i localhost

In the above example the pipeline is triggered on any update of the repository, there is no filtering done in this pipeline, so it will run on every update.
Every time this project is updated, a container is created by the github runner and the ansible-lint is run for the project if the update is in the dev branch.

We see that the image for the container (rh-python-image) to run is pulled from a local registry. This image is a minimal redhat image with python installed and the ansible lint package. So it is not the runner container itself that runs your pipeline!

A workflow is yaml formatted, so multiple commands can be added to the list under 'run:'.

There are near to endless possibilities to what one can do using pipelines, in the end the list under the 'steps/run' key is executed in a bash shell and everything you can do in bash, can be added to the list here.

Multiple stages can be defined with different conditions, read the documentation on the website of github.com.
On this site gitlab is used in almost all pipelines, you can convert these to github pipelines, read the docs at:

Convert gitlab to github pipelines
Be sure to test your changes before running these in production!

Back

Backto Site