From aa11ff3380eeb504ab941017e31a8f06ba79decb Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Thu, 14 Nov 2024 18:34:45 +0100 Subject: [PATCH 01/11] setup worflow to push docker image to ghcr --- .github/workflows/docker-build.yml | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..f24e604 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,32 @@ +name: Build and Push Docker Image +on: + # Trigger the workflow only when a pull request is merged into main + pull_request: + branches: + - main + types: + - closed +jobs: + build: + # Run this job only if the pull request is actually merged + if: github.event.pull_request.merged == true + + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker image + run: | + docker build -t ghcr.io/adorsys-gis/webank-online-banking:latest . + + - name: Push Docker image to GHCR + run: | + docker push ghcr.io/adorsys-gis/webank-online-banking:latest \ No newline at end of file From db1db53071679234d2872c7b1c24bc47b3f66e21 Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 10:38:10 +0100 Subject: [PATCH 02/11] added worflow to test image is pushed to ghcr --- .github/workflows/docker-build.yml | 13 ++++--------- Dockerfile | 13 +++++++++++++ online-banking-app/.gitignore | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index f24e604..66e6e79 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,16 +1,11 @@ -name: Build and Push Docker Image +name: Build and Push Docker Image (Testing) on: - # Trigger the workflow only when a pull request is merged into main - pull_request: + push: branches: - - main - types: - - closed + - test-workflow-for-image + jobs: build: - # Run this job only if the pull request is actually merged - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3e6e85 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# Run stage +FROM openjdk:17-jdk-slim + +WORKDIR /webank-OnlineBanking + +# py the JAR file from the online-banking-app module +COPY ./online-banking-app/target/online-banking-app-0.1-SNAPSHOT.jar /webank-OnlineBanking/online-banking-app-0.1-SNAPSHOT.jar + +# Expose the port your app runs on +EXPOSE 8080 + +# Run the application +CMD ["java", "-jar", "/webank-OnlineBanking/online-banking-app-0.1-SNAPSHOT.jar"] \ No newline at end of file diff --git a/online-banking-app/.gitignore b/online-banking-app/.gitignore index ee6e957..c6e5549 100644 --- a/online-banking-app/.gitignore +++ b/online-banking-app/.gitignore @@ -30,4 +30,4 @@ build/ !**/src/test/**/build/ ### VS Code ### -.vscode/ +.vscode/ \ No newline at end of file From fbd04556d265305fb60514ff74b486edf552d681 Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 10:45:51 +0100 Subject: [PATCH 03/11] added worflow to test image is pushed to ghcr --- .github/workflows/docker-build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 66e6e79..e3a1213 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -2,8 +2,7 @@ name: Build and Push Docker Image (Testing) on: push: branches: - - test-workflow-for-image - + - test-workflow-for-image jobs: build: runs-on: ubuntu-latest From 7d987c465868810e7a3f72e4cecbec037f2059ac Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 11:19:09 +0100 Subject: [PATCH 04/11] added worflow to test image is pushed to ghcr --- .github/workflows/{docker-build.yml => docker-build.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{docker-build.yml => docker-build.yaml} (90%) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yaml similarity index 90% rename from .github/workflows/docker-build.yml rename to .github/workflows/docker-build.yaml index e3a1213..8dba09f 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yaml @@ -1,8 +1,8 @@ name: Build and Push Docker Image (Testing) on: push: - branches: - - test-workflow-for-image + branches: ['test-workflow-for-image'] + workflow_dispatch: jobs: build: runs-on: ubuntu-latest From c78feaadac3d462c47df625f2a7ded4a393ed8aa Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 11:26:24 +0100 Subject: [PATCH 05/11] Test workflow trigger --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..b86c94f --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +Testing workflow trigger From 0beba5de99bbcbd574eb7fe871e74e1241691463 Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 11:26:46 +0100 Subject: [PATCH 06/11] Test workflow trigger --- test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test.txt b/test.txt index b86c94f..faf291b 100644 --- a/test.txt +++ b/test.txt @@ -1 +1,2 @@ Testing workflow trigger +Testing workflow trigger From ce78e63c2700198ff7af7b374d21a4e057cac041 Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 11:37:30 +0100 Subject: [PATCH 07/11] added worflow to test image is pushed to ghcr --- .github/workflows/docker-build.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 8dba09f..6d67b6b 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -10,6 +10,14 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build JAR + run: mvn clean package -DskipTests - name: Log in to GHCR uses: docker/login-action@v3 with: From 294cb31ca3da59e5b041b983b423e0ac16442a5d Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 11:43:12 +0100 Subject: [PATCH 08/11] modified worflow to test image is pushed to ghcr --- .github/workflows/docker-build.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 6d67b6b..08827e1 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -17,7 +17,11 @@ jobs: distribution: 'temurin' - name: Build JAR - run: mvn clean package -DskipTests + run: mvn -f online-banking-app/pom.xml clean package -DskipTests + + - name: Verify JAR File Exists + run: ls -l ./online-banking-app/target/online-banking-app-0.1-SNAPSHOT.jar + - name: Log in to GHCR uses: docker/login-action@v3 with: From 768ea8e8cabee4a93e1561589202abd621f0800e Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 11:56:56 +0100 Subject: [PATCH 09/11] modified worflow to test image is pushed to ghcr --- .github/workflows/docker-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 08827e1..bd60b96 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -1,7 +1,7 @@ name: Build and Push Docker Image (Testing) on: push: - branches: ['test-workflow-for-image'] + branches: ['test-worflow-for-image'] workflow_dispatch: jobs: build: From 2575dcab723b79f00a2846ac353f8c26e9b05fb8 Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 12:14:13 +0100 Subject: [PATCH 10/11] modified worflow to test image is pushed to ghcr --- .github/workflows/docker-build.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index bd60b96..27bfff5 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -15,6 +15,25 @@ jobs: with: java-version: '17' distribution: 'temurin' + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Set up Maven settings.xml + run: | + mkdir -p ~/.m2 + echo " + + + github-webank + ${{ github.actor }} + ${{ secrets.WEBANK_ACCESS_TOKEN }} + + + " > ~/.m2/settings.xml - name: Build JAR run: mvn -f online-banking-app/pom.xml clean package -DskipTests From 71b78560f5150b21a0b3264dd9e89c6320bc50aa Mon Sep 17 00:00:00 2001 From: Elwizzy12 Date: Tue, 19 Nov 2024 12:17:45 +0100 Subject: [PATCH 11/11] modified worflow to test image is pushed to ghcr --- .github/workflows/docker-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index 27bfff5..11901da 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -46,7 +46,7 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.WEBANK_ACCESS_TOKEN}} - name: Build Docker image run: |