diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..9dd5093 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,47 @@ +name: CI-CD with GitOps + +on: + push: + branches: [devops-test] + +jobs: + deploy: + runs-on: ubuntu-latest + env: + IMAGE_NAME: gautamabhis/edutrust-backend + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set Image Tag + run: echo "IMAGE_TAG=build-${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and Push Docker Image + run: | + docker build -t $IMAGE_NAME:$IMAGE_TAG . + docker push $IMAGE_NAME:$IMAGE_TAG + + - name: Trivy Image Scan + uses: aquasecurity/trivy-action@master + with: + image-ref: $IMAGE_NAME:$IMAGE_TAG + format: 'table' + + - name: Update Helm values.yaml + run: | + sed -i "s|tag: .*|tag: \"$IMAGE_TAG\"|" helm/edutrust-chart/values.yaml + + - name: Commit and Push Updated Chart + run: | + git config user.name "github-actions" + git config user.email "actions@github.com" + git add charts/my-app/values.yaml + git commit -m "CI: Update image tag to $IMAGE_TAG" + git push diff --git a/server.ts b/server.ts index 0213d88..3ccc481 100644 --- a/server.ts +++ b/server.ts @@ -19,7 +19,7 @@ app.use(cors( )); app.use(express.json()); app.get('/', (req, res) => { - res.send('Access Blocked ...'); + res.send('Access Blocked for devops test ...'); }); app.use('/api/users/auth',userRoutes);