mirror of
https://github.com/lucky-sideburn/kubeinvaders.git
synced 2026-02-14 17:50:00 +00:00
Merge pull request #96 from Greendor1234/feat/pipeline-improvement
Some checks failed
Docker Image CI / build (push) Failing after 1m19s
Some checks failed
Docker Image CI / build (push) Failing after 1m19s
Github Action
This commit is contained in:
18
.github/workflows/README.md
vendored
Normal file
18
.github/workflows/README.md
vendored
Normal 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`
|
||||
71
.github/workflows/docker-image.yml
vendored
Normal file
71
.github/workflows/docker-image.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
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 registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ vars.REGISTRY_ADDRESS }}
|
||||
username: ${{ secrets.REGISTRY_ROBOT_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_ROBOT_PASSWORD }}
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Lint helm chart
|
||||
run: helm lint helm-charts/kubeinvaders
|
||||
|
||||
- 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: 2000m
|
||||
|
||||
- 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 \
|
||||
--atomic \
|
||||
kubeinvaders \
|
||||
-n kubeinvaders \
|
||||
--create-namespace \
|
||||
helm-charts/kubeinvaders \
|
||||
--set ingress.enabled=true \
|
||||
--set ingress.hostName=kubeinvaders.local \
|
||||
--set-string config.target_namespace="ns-1" \
|
||||
--set deployment.image.tag=${{ env.IMAGE_TAG }} \
|
||||
--set deployment.image.repository=${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_USERNAME }}/kubeinvaders
|
||||
|
||||
- name: Helm test
|
||||
run: |
|
||||
kubectl get all -n kubeinvaders
|
||||
helm test kubeinvaders -n kubeinvaders
|
||||
|
||||
|
||||
Reference in New Issue
Block a user