From 00b6dcf405a2fb6399ec068b65c2d35b41061402 Mon Sep 17 00:00:00 2001 From: sahu04 <105695204+sahu04@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:36:02 +0530 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 548a8fa..38bd333 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,36 +1,36 @@ name: Build and Publish -on: - # run it on push to the default repository branch - #push: - # branches: [master] - - # run it during pull request - release: - pull_request: - branches: - - master +on: [push] + jobs: - run_if: - if: startsWith(github.head_ref, 'releases/') + build_and_publish: runs-on: ubuntu-latest - steps: - - run: echo "The head of this PR starts with 'releases/'" + steps: - name: Checkout code - uses: actions/checkout@v1 - - + uses: actions/checkout@v2 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: build docker images - run: docker build . -t goglang:1.10.0 -f ./guestbook-go/Dockerfile - - name: tag docker image - run: docker tag goglang:1.10.0 dikshasahu/golang-image-new:latest + + - name: Build Docker image + run: docker build . -t goglang:1.10.0 -f ./guestbook-go/Dockerfile + + - name: Tag Docker image + run: docker tag goglang:1.10.0 dikshasahu/golang-image-new:latest1 + + - name: Scan Docker image with Dockle + run: docker run --rm -i hadolint/hadolint < ./guestbook-go/Dockerfile + + - name: Scan Docker image with Trivy + run: trivy image dikshasahu/golang-image-new:latest1 + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Push docker image - run: docker push dikshasahu/golang-image-new:latest + + - name: Push Docker image + run: docker push dikshasahu/golang-image-new:latest1 +