From e5b766475a7a8342c7d65b55fc4397ffc873d4c9 Mon Sep 17 00:00:00 2001
From: Tung Bui <tung.bquang@gmail.com>
Date: Thu, 29 Feb 2024 23:10:20 +0700
Subject: [PATCH 1/9] ci: publish the latest dev image

---
 .github/workflows/docker-image.yml | 37 ++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 08ee822..06d8bfd 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -2,7 +2,13 @@ name: Docker Image CI
 
 on:
   pull_request:
-    branches: [ "main" ]
+    branches: ['main']
+    paths:
+      - 'Dockerfile'
+      - 'scripts/*'
+      - '.github/workflows/*'
+  push:
+    branches: ['main']
     paths:
       - 'Dockerfile'
       - 'scripts/*'
@@ -12,12 +18,25 @@ jobs:
   build:
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v3
-    - name: Build the Docker image
-      run: docker build . --file Dockerfile --tag "devops-toolkit-review:$GITHUB_SHA"
+      - uses: actions/checkout@v3
+
+      - name: Login to Docker Hub
+        uses: docker/login-action@v3
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+      - name: Build the Docker image
+        run: docker build . --file Dockerfile --tag "devops-toolkit-merge:$GITHUB_SHA"
+
+      - name: Verify tool versions
+        run: |
+          cd scripts
+          chmod +x check_version_in_toolkit.sh
+          ./check_version_in_toolkit.sh "devops-toolkit-merge:$GITHUB_SHA"
 
-    - name: Verify tool versions
-      run: |
-        cd scripts
-        chmod +x check_version_in_toolkit.sh
-        ./check_version_in_toolkit.sh "devops-toolkit-review:$GITHUB_SHA"
+      - name: Push Docker Image
+        if: github.event_name == 'push' && github.ref == 'refs/heads/main'
+        run: |
+          docker tag "devops-toolkit-merge:$GITHUB_SHA" "tungbq/devops-toolkit:main-${GITHUB_SHA::7}"
+          # docker push "tungbq/devops-toolkit:main-${GITHUB_SHA::7}"

From b2b78bbde914cc85fcde8fd584e3ae18d12e7fa9 Mon Sep 17 00:00:00 2001
From: Tung Bui <tung.bquang@gmail.com>
Date: Thu, 29 Feb 2024 23:10:38 +0700
Subject: [PATCH 2/9] ci: publish the latest dev image.v1

---
 .github/workflows/docker-image.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 06d8bfd..d32e6c2 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -36,7 +36,7 @@ jobs:
           ./check_version_in_toolkit.sh "devops-toolkit-merge:$GITHUB_SHA"
 
       - name: Push Docker Image
-        if: github.event_name == 'push' && github.ref == 'refs/heads/main'
+        # if: github.event_name == 'push' && github.ref == 'refs/heads/main'
         run: |
           docker tag "devops-toolkit-merge:$GITHUB_SHA" "tungbq/devops-toolkit:main-${GITHUB_SHA::7}"
           # docker push "tungbq/devops-toolkit:main-${GITHUB_SHA::7}"

From 59efb051b38073dcff4db3f11abd0e9066f7cfd6 Mon Sep 17 00:00:00 2001
From: Tung Bui <tung.bquang@gmail.com>
Date: Thu, 29 Feb 2024 23:20:40 +0700
Subject: [PATCH 3/9] ci: publish the latest dev image.v3env

---
 .github/workflows/docker-image.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index d32e6c2..87a556a 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -17,6 +17,7 @@ on:
 jobs:
   build:
     runs-on: ubuntu-latest
+    environment: docker
     steps:
       - uses: actions/checkout@v3
 

From a9d7415806ef99b83322b4b3b19ba558be28360c Mon Sep 17 00:00:00 2001
From: Tung Bui <tung.bquang@gmail.com>
Date: Thu, 29 Feb 2024 23:23:09 +0700
Subject: [PATCH 4/9] ci: publish the latest dev image.v4

---
 .github/workflows/docker-image.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 87a556a..d32e6c2 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -17,7 +17,6 @@ on:
 jobs:
   build:
     runs-on: ubuntu-latest
-    environment: docker
     steps:
       - uses: actions/checkout@v3
 

From fa7b943a14733d3aec775e3c5e4883988767dcdb Mon Sep 17 00:00:00 2001
From: Tung Bui <tung.bquang@gmail.com>
Date: Thu, 29 Feb 2024 23:30:12 +0700
Subject: [PATCH 5/9] ci: fix secret permission

---
 .github/workflows/docker-image.yml | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index d32e6c2..1b76340 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -13,6 +13,8 @@ on:
       - 'Dockerfile'
       - 'scripts/*'
       - '.github/workflows/*'
+permissions:
+  contents: read
 
 jobs:
   build:
@@ -38,5 +40,7 @@ jobs:
       - name: Push Docker Image
         # if: github.event_name == 'push' && github.ref == 'refs/heads/main'
         run: |
-          docker tag "devops-toolkit-merge:$GITHUB_SHA" "tungbq/devops-toolkit:main-${GITHUB_SHA::7}"
-          # docker push "tungbq/devops-toolkit:main-${GITHUB_SHA::7}"
+          SHA7=${GITHUB_SHA::7}
+          docker tag "devops-toolkit-merge:$GITHUB_SHA" "tungbq/devops-toolkit:main-$SHA7"
+          docker images
+          # docker push "tungbq/devops-toolkit:main-$SHA7"

From 19a09a1b4515c05e37a99fd5e7f1addafb4a5b25 Mon Sep 17 00:00:00 2001
From: Tung Bui <tung.bquang@gmail.com>
Date: Thu, 29 Feb 2024 23:35:58 +0700
Subject: [PATCH 6/9] ci: fix secret permission.v2

---
 .github/workflows/docker-image.yml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 1b76340..efd20de 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -13,8 +13,7 @@ on:
       - 'Dockerfile'
       - 'scripts/*'
       - '.github/workflows/*'
-permissions:
-  contents: read
+permissions: read-all
 
 jobs:
   build:

From 354d0d15b7c960550ce715c56bab057701469549 Mon Sep 17 00:00:00 2001
From: Tung Leo <tung.bquang@gmail.com>
Date: Fri, 1 Mar 2024 18:03:38 +0700
Subject: [PATCH 7/9] Update docker-image.yml

---
 .github/workflows/docker-image.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index efd20de..20a4193 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -13,7 +13,6 @@ on:
       - 'Dockerfile'
       - 'scripts/*'
       - '.github/workflows/*'
-permissions: read-all
 
 jobs:
   build:

From 3211c23d332578aafceb233b203cdb06bb0b85da Mon Sep 17 00:00:00 2001
From: Tung Bui <tung.bquang@gmail.com>
Date: Fri, 1 Mar 2024 18:09:41 +0700
Subject: [PATCH 8/9] ci: fix docker login

---
 .github/workflows/docker-image.yml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 20a4193..457fbe6 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -18,13 +18,12 @@ jobs:
   build:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
-
       - name: Login to Docker Hub
         uses: docker/login-action@v3
         with:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
+      - uses: actions/checkout@v3
 
       - name: Build the Docker image
         run: docker build . --file Dockerfile --tag "devops-toolkit-merge:$GITHUB_SHA"

From 0d76250f0199d33ee128547b09d444af2ce7b9f6 Mon Sep 17 00:00:00 2001
From: Tung Bui <tung.bquang@gmail.com>
Date: Fri, 1 Mar 2024 18:14:43 +0700
Subject: [PATCH 9/9] ci: fix docker login

---
 .github/workflows/docker-image.yml | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 457fbe6..0ec1a65 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -18,15 +18,12 @@ jobs:
   build:
     runs-on: ubuntu-latest
     steps:
-      - name: Login to Docker Hub
-        uses: docker/login-action@v3
-        with:
-          username: ${{ secrets.DOCKERHUB_USERNAME }}
-          password: ${{ secrets.DOCKERHUB_TOKEN }}
       - uses: actions/checkout@v3
 
       - name: Build the Docker image
-        run: docker build . --file Dockerfile --tag "devops-toolkit-merge:$GITHUB_SHA"
+        run: |
+          docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
+          docker build . --file Dockerfile --tag "devops-toolkit-merge:$GITHUB_SHA"
 
       - name: Verify tool versions
         run: |
