Build #52
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 | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- uses: sonarsource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
- name: NPM Install | |
run: npm install | |
- name: Docker build and push | |
run: | | |
# Run commands to build and push Docker images | |
docker build -t swiggy-clone . | |
docker tag swiggy-clone aakibkhan1212/swiggy-clone:latest | |
docker login -u ${{ secrets.Dockerhub_username }} -p ${{ secrets.Dockerhub_token }} | |
docker push aakibkhan1212/swiggy-clone:latest | |
env: | |
DOCKER_CLI_ACI: 1 | |
deploy: | |
needs: build | |
runs-on: [self-hosted] | |
steps: | |
- name: docker pull image | |
run: docker pull aakibkhan1212/swiggy-clone:latest | |
- name: Image scan | |
run: trivy image aakibkhan1212/swiggy-clone:latest > trivyimagedeploy.txt | |
- name: Deploy to container | |
run: docker run -d --name swiggy-clone -p 3000:3000 aakibkhan1212/swiggy-clone:latest | |
- name: Update kubeconfig | |
run: aws eks --region ap-south-1 update-kubeconfig --name EKS_CLOUD | |
- name: Deploy to kubernetes | |
run: kubectl apply -f deployment-service.yml |