Merge pull request #6 from mohamad-liyaghi/dependabot/go_modules/serv… #63
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: Build, Test and Deploy Users Service | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Docker | |
uses: docker/setup-buildx-action@v2 | |
- name: Build The Image | |
working-directory: services/users/ | |
run: make build | |
test-on-docker: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Docker | |
uses: docker/setup-buildx-action@v2 | |
- name: Create Shared Network | |
run: docker network create shared-service-network | |
- name: Build The Image | |
working-directory: services/users/ | |
run: make build | |
- name: Run The Service | |
working-directory: services/users/ | |
run: make run DETACHED=true | |
- name: Run The Tests | |
working-directory: services/users/ | |
run: make test | |
test-on-kubernetes: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: debianmaster/actions-k3s@master | |
id: k3s | |
with: | |
version: 'latest' | |
- name: Create ConfigMap | |
working-directory: services/users/ | |
run: make confmap | |
- name: Run Kubernetes Deployments | |
run: kubectl apply -f k8s/users/ | |
- name: Wait for Database Deployments | |
run: kubectl wait --for=condition=available --timeout=60s deployment/jobhunt-users-postgres | |
- name: Wait for Backend Deployments | |
run: kubectl wait --for=condition=available --timeout=60s deployment/jobhunt-users-backend | |
- name: Run Backend Tests | |
run: kubectl exec -it $(kubectl get pods | grep backend | awk '{print $1}') -- python -m pytest tests/ | |
deploy: | |
needs: [test-on-docker, test-on-kubernetes] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Fake Deployment | |
run: echo "Deploying the service to the cloud..." |