From 2e89f6c8091d8c8687e39fb87b733f09778d2e59 Mon Sep 17 00:00:00 2001 From: "Ananth Kannan (Coach AK)" <15877864+akannan1087@users.noreply.github.com> Date: Sat, 6 Apr 2024 17:34:54 -0500 Subject: [PATCH] Created CICD yaml file for creating docker image and pushing into Dockerhub --- .github/workflows/main.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9883679 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,27 @@ +name: cicd-workflow to create docker image and upload into Dockerhub +on: + push: + branches: [ "master" ] +jobs: + job1: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '17' + - name: Build with Maven + run: mvn clean install + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push Docker image + env: + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/myspringbootapp:${IMAGE_TAG} . + docker push ${{ secrets.DOCKERHUB_USERNAME }}/myspringbootapp:${IMAGE_TAG}