Skip to content
Open
33 changes: 0 additions & 33 deletions .github/backups/user_app_ci.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/backups/user_app_ci_k8s.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# documentation can be found at: https://minikube.sigs.k8s.io/docs/tutorials/setup_minikube_in_github_actions/
name: User App CI

on:
push:
branches: [ master ]
pull_request:
branches: [ '*' ]

jobs:

user_app_ci:

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v3
- name: Start minikube
uses: medyagh/setup-minikube@master

- name: Deploying Services to K8s
run: |
echo "------------------ list all available pods ------------------"
kubectl get pods -A
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
docker build -t user-app ./app
docker build -t user-service ./user_service
echo -n "verifying images:"
docker images
echo "------------------ deploying to minikube ------------------"
kubectl apply -f infrastructure/my_network-networkpolicy.yaml
kubectl apply -f infrastructure/user-app-deployment.yaml
kubectl apply -f infrastructure/user-app-service.yaml
kubectl apply -f infrastructure/user-service-deployment.yaml
kubectl apply -f infrastructure/user-service-service.yaml
echo "------------------ waiting for pod availability ------------------"
echo $pod_name
kubectl wait --for=condition=Ready pod/$(kubectl get pods --no-headers -o custom-columns=":metadata.name" | grep user-app) -n default --timeout=60s
echo "------------------ forwarding port for user-app ------------------"
kubectl port-forward deployment/user-app 5000:5000 &
PORT_FORWARD_PID=$!

- name: Preparing Test Environment
uses: actions/setup-python@v2
- run: |
pip install pytest
pip install requests

- name: Test
run: pytest tests/backend_tests/
72 changes: 27 additions & 45 deletions .github/workflows/user_app_ci.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,34 @@
# documentation can be found at: https://minikube.sigs.k8s.io/docs/tutorials/setup_minikube_in_github_actions/
name: User App CI
name: Create Git Tag

on:
push:
branches: [ master ]
pull_request:
branches: [ '*' ]
branches: [ 'master' ]

jobs:

user_app_ci:

create-git-tag:
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v3
- name: Start minikube
uses: medyagh/setup-minikube@master

- name: Deploying Services to K8s
run: |
echo "------------------ list all available pods ------------------"
kubectl get pods -A
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
docker build -t user-app ./app
docker build -t user-service ./user_service
echo -n "verifying images:"
docker images
echo "------------------ deploying to minikube ------------------"
kubectl apply -f infrastructure/my_network-networkpolicy.yaml
kubectl apply -f infrastructure/user-app-deployment.yaml
kubectl apply -f infrastructure/user-app-service.yaml
kubectl apply -f infrastructure/user-service-deployment.yaml
kubectl apply -f infrastructure/user-service-service.yaml
echo "------------------ waiting for pod availability ------------------"
echo $pod_name
kubectl wait --for=condition=Ready pod/$(kubectl get pods --no-headers -o custom-columns=":metadata.name" | grep user-app) -n default --timeout=60s
echo "------------------ forwarding port for user-app ------------------"
kubectl port-forward deployment/user-app 5000:5000 &
PORT_FORWARD_PID=$!

- name: Preparing Test Environment
uses: actions/setup-python@v2
- run: |
pip install pytest
pip install requests

- name: Test
run: pytest tests/backend_tests/
- name: Get current date
id: date
run: echo "date=$(date +'+%Y_%m_%d___%H_%M_%S')" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
name: Get head git commit message
id: commit-msg
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: echo "commit-msg=$(git show -s --format=%s)" >> $GITHUB_ENV
- name: Commit files
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag -a ${{ env.date }} -m "${{ env.commit-msg }}"
- name: Push changes
uses: ad-m/github-push-action@master
with:
force: true
tags: true
branch: ${{ github.head_ref }}