From 001ef0ae43a47519cfa653168b462995a4f1396e Mon Sep 17 00:00:00 2001 From: BanulaKumarage Date: Fri, 26 Apr 2024 16:26:58 +0530 Subject: [PATCH] Add pipeline to dockerize and push --- .github/workflows/build.yaml | 40 ++++++++++++++++++++++++++++++++++++ pom.xml | 10 +++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..aed86af --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,40 @@ +name: Build and Push Docker Image + +permissions: + contents: write + packages: write + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + + env: + IMAGE_NAME: distributed-node + IMAGE_TAG: latest + + steps: + - name: Set up Git repository + uses: actions/checkout@v2 + with: + token: ${{ secrets.PAT }} + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build Docker image and push to GitHub Container Registry + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + ./mvnw clean compile jib:dockerBuild + docker tag distributed-file-server:0.0.1-SNAPSHOT ghcr.io/scatterrr-cse19/$IMAGE_NAME:$IMAGE_TAG + docker push ghcr.io/scatterrr-cse19/$IMAGE_NAME:$IMAGE_TAG \ No newline at end of file diff --git a/pom.xml b/pom.xml index 5fb589f..b9f6d32 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,16 @@ + + com.google.cloud.tools + jib-maven-plugin + 3.2.1 + + + eclipse-temurin:17.0.4.1_1-jre + + +