diff --git a/.github/backups/user_app_ci.yml b/.github/backups/user_app_ci.yml deleted file mode 100644 index c9111d5..0000000 --- a/.github/backups/user_app_ci.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: User App CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ '*' ] - -jobs: - - user_app_ci: - - runs-on: ubuntu-latest - - steps: - - - name: build - uses: actions/checkout@v2 - - run: | - docker network create my-network - docker-compose up -d --build - - - name: prepare test environment - uses: actions/setup-python@v2 - - run: | - pip install pytest - pip install requests - - - name: test - run: pytest tests/backend_tests/ - - - name: clean - run: docker-compose down \ No newline at end of file diff --git a/.github/backups/user_app_ci_k8s.yml b/.github/backups/user_app_ci_k8s.yml new file mode 100644 index 0000000..3ddfa17 --- /dev/null +++ b/.github/backups/user_app_ci_k8s.yml @@ -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/ \ No newline at end of file diff --git a/.github/workflows/user_app_ci.yml b/.github/workflows/user_app_ci.yml index 3ddfa17..e92d43d 100644 --- a/.github/workflows/user_app_ci.yml +++ b/.github/workflows/user_app_ci.yml @@ -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/ \ No newline at end of file + - 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 }} \ No newline at end of file