added test cases #3
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: Github actions | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-deploy: | |
name: Build and deploy E-Commerce Backend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: SetUp JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'corretto' | |
java-version: 17 | |
- name: Unit Tests | |
run: | | |
cd ecommerce/ | |
mvn -B test --file pom.xml | |
- name: Build the application | |
run: | | |
cd ecommerce/ | |
mvn clean | |
mvn -B package --file pom.xml | |
- name: Build Docker Image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: false | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/Ecommerce_app:latest | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push to Docker Hub | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: ${{secrets.DOCKERHUB_USERNAME}}/Ecommerce_app:latest |