11name : CICD Pipeline
22on :
33 push :
4- branches : [ 'main' ]
4+ branches :
5+ - main
56 pull_request :
7+ branches :
8+ - main
69
710jobs :
811 build :
@@ -111,4 +114,46 @@ jobs:
111114 scan-ref : ' ./'
112115 exit-code : 1
113116 severity : ' CRITICAL,HIGH'
114- trivy-config : ./config/trivy/trivy.yaml
117+ trivy-config : ./config/trivy/trivy.yaml
118+ docker-build-push :
119+ if : github.ref == 'refs/heads/main'
120+ runs-on : ubuntu-latest
121+ needs :
122+ - unit-test
123+ - mutation-test
124+ - dependency-vulnerability-analysis
125+ - sast-code-snyk
126+ - sast-dockerfile-trivy-hadolint
127+ steps :
128+ - name : Login to Docker Hub
129+ uses : docker/login-action@v3
130+ with :
131+ username : ${{ vars.DOCKERHUB_USERNAME }}
132+ password : ${{ secrets.DOCKERHUB_TOKEN }}
133+ - name : Set up Docker Buildx
134+ uses : docker/setup-buildx-action@v3
135+ - name : Docker meta
136+ id : meta
137+ uses : docker/metadata-action@v5
138+ with :
139+ images : |
140+ abhisheksr01/companieshouse
141+ tags : |
142+ type=ref,event=branch
143+ type=ref,event=pr
144+ type=semver,pattern={{version}}
145+ type=semver,pattern={{major}}.{{minor}}
146+ labels : |
147+ "org.opencontainers.image.title": "abhisheksr01/companieshouse",
148+ "org.opencontainers.image.description": "Best practices and integrations available for Spring Boot based Microservice in a single repository with companieshouse API use case.",
149+ "org.opencontainers.image.url": "https://github.com/abhisheksr01/spring-boot-microservice-best-practices",
150+ "org.opencontainers.image.source": "https://github.com/abhisheksr01/spring-boot-microservice-best-practices",
151+ "org.opencontainers.image.version": "0.1.0",
152+ "org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
153+ "org.opencontainers.image.revision": ${{ github.sha }},
154+ "org.opencontainers.image.licenses": "MIT"
155+ - name : Build and push
156+ uses : docker/build-push-action@v6
157+ with :
158+ push : true
159+ tags : abhisheksr01/companieshouse:latest
0 commit comments