Create build pipeline

This commit is contained in:
Alessandro Bitocchi
2025-02-19 16:46:59 +01:00
committed by Greendor1234
parent c3301d8598
commit 53e11c54f3
2 changed files with 84 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
# Github Actions
This folder contains the definition of a Github action used to build and push the image into a registry and also to setup a minikube cluster to test the deployment of the helm chart.
## setup
In order to use Github Actions for your repository it's necessary to setup two secrets and two environment variables in your project settings.
1. In Github go into your repository then click `Settings`
2. On left side you can see a section called `Security`
3. Click on `Secrets and variables` -> `Actions`
4. Add the secret `REGISTRY_ROBOT_PASSWORD` (the password used to access to the image registry)
5. Add the secret `REGISTRY_ROBOT_USERNAME` (the username used to access to the image registry)
6. Add the variable `REGISTRY_ADDRESS` (the address of the image registry, could be quay.io or docker.io)
7. Add the variable `REGISTRY_USERNAME` (the username used in the image registry)
Once these variables have been setted it is possible to run the action and see the output
**NOTE**: the action build and push the image with the default tag `latest`
+66
View File
@@ -0,0 +1,66 @@
name: Docker Image CI
on:
push:
branches: [ "master", "feat/pipeline-improvement" ]
pull_request:
branches: [ "master" ]
env:
IMAGE_TAG: ${{ github.event_name == 'push' && 'latest' || 'latest-pull-request' }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.REGISTRY_ROBOT_USERNAME }}
password: ${{ secrets.REGISTRY_ROBOT_PASSWORD }}
- uses: actions/checkout@v4
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag ${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_USERNAME }}/kubeinvaders:${{ env.IMAGE_TAG }}
docker push ${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_USERNAME }}/kubeinvaders:${{ env.IMAGE_TAG }}
- name: Start minikube
uses: medyagh/setup-minikube@latest
with:
driver: docker
kubernetes-version: v1.26.3
cpus: 4
memory: 2048m
- name: Try the cluster!
run: kubectl get pods -A
- name: Deploy example
run: |
kubectl apply -f minikube-setup/manifests --wait=true
kubectl get all -n "ns-1"
- name: Deploy with helm
run: |
helm upgrade --install \
kubeinvaders \
-n kubeinvaders \
--create-namespace \
helm-charts/kubeinvaders \
--set ingress.enabled=true \
--set deployment.image.tag=latest \
--set ingress.hostName=kubeinvaders.local \
--set-string config.target_namespace="ns-1" \
--set deployment.image.repository=${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_USERNAME }}
- name: Check if service is available
run: |
kubectl get all -n kubeinvaders