From f3284bdc15d01eebb867edc791e576efc277281f Mon Sep 17 00:00:00 2001 From: Mukul Chandrakant Mahadik Date: Mon, 18 Mar 2024 11:16:35 -0700 Subject: [PATCH 1/9] Create image_build_push.yml --- .github/workflows/image_build_push.yml | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/image_build_push.yml diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml new file mode 100644 index 0000000..c784d98 --- /dev/null +++ b/.github/workflows/image_build_push.yml @@ -0,0 +1,48 @@ +# This is a basic workflow to help you get started with Actions + +name: docker-image-push-join + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ image-push-merge ] + + +# Env variable +env: + DOCKER_USER: ${{secrets.DOCKER_USER}} + DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - name: docker login + run: | # log into docker hub account + docker login -u $DOCKER_USER -p $DOCKER_PASSWORD + + - name: Get current date # get the date of the build + id: date + run: echo "::set-output name=date::$(date +'%Y-%m-%d--%M-%S')" + + #Runs a single command using the runners shell + - name: Run a one-line script + run: echo running in repo ${GITHUB_REPOSITORY#*/} branch ${GITHUB_REF##*/} on ${{ steps.date.outputs.date }} + + # Runs a set of commands using the runners shell + - name: build docker image + run: | + docker build -t $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} . + docker images + + - name: push docker image + run: | + docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} From 918deca4521424c1f0da9a636747d5fda086c086 Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Mon, 18 Mar 2024 11:54:40 -0700 Subject: [PATCH 2/9] Print docker username --- .github/workflows/image_build_push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index c784d98..4d31075 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -27,6 +27,7 @@ jobs: - uses: actions/checkout@v2 - name: docker login run: | # log into docker hub account + echo $$DOCKER_USER docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - name: Get current date # get the date of the build From c979e41a852e98d6b0ae4b4a2b83ed96835884b5 Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Mon, 18 Mar 2024 11:57:43 -0700 Subject: [PATCH 3/9] Remove extra $ sign --- .github/workflows/image_build_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 4d31075..4c12236 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v2 - name: docker login run: | # log into docker hub account - echo $$DOCKER_USER + echo $DOCKER_USER docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - name: Get current date # get the date of the build From 97bf66e974cdf20ec25ce15dc1e8adfb8067d58a Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Mon, 18 Mar 2024 12:05:37 -0700 Subject: [PATCH 4/9] Add print label --- .github/workflows/image_build_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 4c12236..64385cb 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v2 - name: docker login run: | # log into docker hub account - echo $DOCKER_USER + echo "Docker username: " $DOCKER_USER docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - name: Get current date # get the date of the build From 5da18bb124520e9559faa77718ab60cca4b670b7 Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Mon, 18 Mar 2024 12:10:00 -0700 Subject: [PATCH 5/9] Space commit --- .github/workflows/image_build_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 64385cb..4c96d68 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v2 - name: docker login run: | # log into docker hub account - echo "Docker username: " $DOCKER_USER + echo "Docker user name: " $DOCKER_USER docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - name: Get current date # get the date of the build From 41653336401511b751737d0e8e93d316cf4ef8fc Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Mon, 18 Mar 2024 12:17:52 -0700 Subject: [PATCH 6/9] Added correct path to Dockerfile --- .github/workflows/image_build_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 4c96d68..027ed2a 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -41,7 +41,7 @@ jobs: # Runs a set of commands using the runners shell - name: build docker image run: | - docker build -t $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} . + docker build -t $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} ./frontend docker images - name: push docker image From 14fb3f7a7ea3cab9df0117466d774b529d4ca680 Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Tue, 26 Mar 2024 10:38:17 -0700 Subject: [PATCH 7/9] Added TODO to change image push branch Currently the branch specified - "image-push-merge" is available locally on my system. I use it to test the automated docker image push mechanism whenever any changes are merged to this branch. Once, everything looks good, need to change this to master or main as per the repo. --- .github/workflows/image_build_push.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 027ed2a..6631b2f 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -6,6 +6,10 @@ name: docker-image-push-join # events but only for the master branch on: push: + # Mukul: + # I've added a local test branch on my system and using it for testing image push. + # So, for testing purposes, need to checkout a branch "image-push-merge" + # TODO: Need to change to build off master or main once it looks good. branches: [ image-push-merge ] From 6fa9573298b2cb7dc3b7f59a7bcbc424a10891eb Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Tue, 26 Mar 2024 11:18:02 -0700 Subject: [PATCH 8/9] Removed printing Docker username Had added it initially for testing purposes. Can remove now so it doesn't expose any sensitive info. --- .github/workflows/image_build_push.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 6631b2f..1c4fb76 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -31,7 +31,6 @@ jobs: - uses: actions/checkout@v2 - name: docker login run: | # log into docker hub account - echo "Docker user name: " $DOCKER_USER docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - name: Get current date # get the date of the build From 20577667e33a972a9e133964e49cd50e2007102f Mon Sep 17 00:00:00 2001 From: Natalie Schultz <90212258+nataliejschultz@users.noreply.github.com> Date: Wed, 8 May 2024 17:36:16 -0600 Subject: [PATCH 9/9] Polishing image_build_push.yml Will run on push to main; removed extraneous comments --- .github/workflows/image_build_push.yml | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/.github/workflows/image_build_push.yml b/.github/workflows/image_build_push.yml index 1c4fb76..820e8ac 100644 --- a/.github/workflows/image_build_push.yml +++ b/.github/workflows/image_build_push.yml @@ -1,33 +1,21 @@ -# This is a basic workflow to help you get started with Actions - name: docker-image-push-join -# Controls when the action will run. Triggers the workflow on push or pull request -# events but only for the master branch on: push: - # Mukul: - # I've added a local test branch on my system and using it for testing image push. - # So, for testing purposes, need to checkout a branch "image-push-merge" - # TODO: Need to change to build off master or main once it looks good. - branches: [ image-push-merge ] - + branches: [ main ] -# Env variable env: DOCKER_USER: ${{secrets.DOCKER_USER}} DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" + build: - # The type of runner that the job will run on + runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 - name: docker login run: | # log into docker hub account @@ -37,11 +25,9 @@ jobs: id: date run: echo "::set-output name=date::$(date +'%Y-%m-%d--%M-%S')" - #Runs a single command using the runners shell - name: Run a one-line script run: echo running in repo ${GITHUB_REPOSITORY#*/} branch ${GITHUB_REF##*/} on ${{ steps.date.outputs.date }} - # Runs a set of commands using the runners shell - name: build docker image run: | docker build -t $DOCKER_USER/${GITHUB_REPOSITORY#*/}:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} ./frontend