added a while loop in the workflow to know when the pod is ready #249
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI-testing | |
on: | |
# schedule: | |
# - cron: '0 8,20 * * *' | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
repository_dispatch: | |
types: | |
- trigger-ci-testing | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
name: build example and deploy to minikube | |
steps: | |
- name: clone application from github repo. | |
uses: sudosubin/[email protected] | |
with: | |
repository: 'ZivAmram/mahat-project-app' | |
platform: 'github' | |
- name: enter the folder. | |
run: ls | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: build docker image | |
run: | | |
docker build -t zivamram/trading-app:0.0.${{ github.run_id }} . | |
- name: Docker Login | |
uses: docker/login-action@v2 | |
with: | |
username: zivamram | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: docker push | |
run: | | |
docker push zivamram/trading-app:0.0.${{ github.run_id }} | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Update Deployment Manifest | |
run: | | |
ls | |
sed -i "s|image: zivamram/trading-app:.*|image: zivamram/trading-app:0.0.${{ github.run_id }}|" ./trading-app.yaml | |
- name: Ensure the trading-app.yaml | |
run: | | |
cat trading-app.yaml | |
- name: Start minikube | |
uses: medyagh/setup-minikube@master | |
- name: Try the cluster ! | |
run: kubectl get pods -A | |
- name: Deploy to minikube | |
run: | | |
kubectl apply -f mongo.yaml | |
kubectl apply -f mongo-svc.yaml | |
kubectl apply -f mongo-pv.yaml | |
kubectl apply -f mongo-pvc.yaml | |
kubectl apply -f trading-app.yaml | |
kubectl apply -f trading-app-svc.yaml | |
- name: Wait for Pods to be running | |
run: | | |
SECONDS=0 | |
TIMEOUT=600 # Set your desired timeout in seconds here | |
while [[ $(kubectl get pods -n project -l app=project -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do | |
if [[ $SECONDS -gt $TIMEOUT ]]; then | |
echo "Timed out waiting for pods to be ready" | |
exit 1 | |
fi | |
kubectl get pods -n project | |
sleep 1 | |
done | |
- name: Check pods | |
run: | | |
kubectl get pods | |
- name: Test Login To App | |
run: | | |
docker images | |
minikube service list | |
kubectl get pods | |
minikube service trading-app-svc --url | |
echo "---------------opening the service----------------" | |
curl $(minikube service trading-app-svc --url)/ | |
curl -X POST -d "name=TEST&[email protected]&password=test" $(minikube service trading-app-svc --url)/user/signup | |
curl -X POST -d "[email protected]&password=test" $(minikube service trading-app-svc --url)/user/login | |
- name: push to github | |
uses: github-actions-x/[email protected] | |
with: | |
github-token: ${{ secrets.GH_TOKEN }} | |
push-branch: 'main' | |
commit-message: 'publish' | |
force-add: 'true' | |
files: trading-app.yaml | |
name: Ziv | |
email: [email protected] |