From 88a4de1e3475587d0d2f0126ce4c7edb38075927 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 10:04:10 +1000 Subject: [PATCH 01/40] create build steps for staging --- .github/workflows/build-staging.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/build-staging.yml diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml new file mode 100644 index 00000000..0c21ea5c --- /dev/null +++ b/.github/workflows/build-staging.yml @@ -0,0 +1,29 @@ +name: Build and push the latest build to staging + +on: + push: + branches: [ main ] + +jobs: + build_push_image: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Buildx + uses: docker/setup-buildx-action@v1 + + - name: Docker Login + uses: docker/login-action@v1.8.0 + with: + registry: ${{ secrets.ACR_NAME }} + username: ${{ secrets.ACR_LOGIN }} + password: ${{ secrets.ACR_PASSWORD }} + + - name: Build and push staging images + uses: docker/build-push-action@v2.4.0 + with: + context: . + tags: latest + repository: contoso-website From 32711449490127bd34ff9f504bb862b823f55d76 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 10:21:16 +1000 Subject: [PATCH 02/40] updated --- .github/workflows/build-staging.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 0c21ea5c..937adf18 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -26,4 +26,3 @@ jobs: with: context: . tags: latest - repository: contoso-website From cb3daddeaf06c6b8da6c1ea10f1b4e396b735f16 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 11:02:33 +1000 Subject: [PATCH 03/40] Update build-staging.yml --- .github/workflows/build-staging.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 937adf18..38647c89 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -26,3 +26,4 @@ jobs: with: context: . tags: latest + push: true From 9e207c5821f7798648d77b775e56bbe5e0563859 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 11:17:39 +1000 Subject: [PATCH 04/40] Update build-staging.yml --- .github/workflows/build-staging.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 38647c89..937adf18 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -26,4 +26,3 @@ jobs: with: context: . tags: latest - push: true From be53e7062627f4ff6c9a9e11a83a1181249f2dc0 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 11:48:13 +1000 Subject: [PATCH 05/40] Update build-staging.yml --- .github/workflows/build-staging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 937adf18..ddf3898a 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -25,4 +25,4 @@ jobs: uses: docker/build-push-action@v2.4.0 with: context: . - tags: latest + tags: contoso-website:latest From f58c1be0e3b733eabbc5d2c4513f639dbc7f26ad Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 11:53:24 +1000 Subject: [PATCH 06/40] Update build-staging.yml --- .github/workflows/build-staging.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index ddf3898a..79a42259 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -26,3 +26,4 @@ jobs: with: context: . tags: contoso-website:latest + push: true From e11275a9d24420401f193213d3aeb51ccb63e9c5 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 11:57:54 +1000 Subject: [PATCH 07/40] Update build-staging.yml --- .github/workflows/build-staging.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 79a42259..4f894ae5 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -15,9 +15,9 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Docker Login - uses: docker/login-action@v1.8.0 + uses: Azure/docker-login@v1 with: - registry: ${{ secrets.ACR_NAME }} + login-server: ${{ secrets.ACR_NAME }} username: ${{ secrets.ACR_LOGIN }} password: ${{ secrets.ACR_PASSWORD }} @@ -25,5 +25,4 @@ jobs: uses: docker/build-push-action@v2.4.0 with: context: . - tags: contoso-website:latest - push: true + tags: latest From d8c938cf2dfb611396a4f6576f2e4c0f8213f93c Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 12:32:36 +1000 Subject: [PATCH 08/40] Update build-staging.yml --- .github/workflows/build-staging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 4f894ae5..7d73e9a5 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -25,4 +25,4 @@ jobs: uses: docker/build-push-action@v2.4.0 with: context: . - tags: latest + tags: ${{ secrets.ACR_NAME }}/contoso-website:latest From d768baa50b92331d6c93e9f0c235552860ab8b7d Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 12:35:07 +1000 Subject: [PATCH 09/40] Update build-staging.yml --- .github/workflows/build-staging.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 7d73e9a5..aab63725 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -26,3 +26,4 @@ jobs: with: context: . tags: ${{ secrets.ACR_NAME }}/contoso-website:latest + push: true From 038fee8073345e63e9a915172cf8669b542e9e7a Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Fri, 11 Jun 2021 13:06:27 +1000 Subject: [PATCH 10/40] Update build-staging.yml --- .github/workflows/build-staging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index aab63725..964b139f 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -15,9 +15,9 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Docker Login - uses: Azure/docker-login@v1 + uses: docker/login-action@v1.9.0 with: - login-server: ${{ secrets.ACR_NAME }} + registry: ${{ secrets.ACR_NAME }} username: ${{ secrets.ACR_LOGIN }} password: ${{ secrets.ACR_PASSWORD }} From 47c6ec0aa82c74de063c901041cab95c68c4317f Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 15:27:09 +1000 Subject: [PATCH 11/40] production pipeline --- .github/workflows/build-production.yml | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/build-production.yml diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml new file mode 100644 index 00000000..1621c5ba --- /dev/null +++ b/.github/workflows/build-production.yml @@ -0,0 +1,44 @@ +name: Build and push the tagged build to production + +on: + push: + tags: + - 'v*' + +# 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 Setup Buildx + # You may pin to the exact commit or the version. + # uses: docker/setup-buildx-action@0d135e0c2fc0dba0729c1a47ecfcf5a3c7f8579e + uses: docker/setup-buildx-action@v1.3.0 + + # Runs a single command using the runners shell + - name: Docker Login + # You may pin to the exact commit or the version. + # uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + uses: docker/login-action@v1.9.0 + with: + registry: ${{ secrets.ACR_NAME }} + username: ${{ secrets.ACR_LOGIN }} + password: ${{ secrets.ACR_PASSWORD }} + + + - name: Build and push Docker images + # You may pin to the exact commit or the version. + # uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v2.5.0 + with: + context: . + tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF#refs/tags} + push: true + From 807c8474db655354d87d3c282905c2896553fa6c Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 15:41:35 +1000 Subject: [PATCH 12/40] test --- test file | 1 + 1 file changed, 1 insertion(+) create mode 100644 test file diff --git a/test file b/test file new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/test file @@ -0,0 +1 @@ +test From 4837f9d34c525889d9ecadf79d8ada1fd3b55c40 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 15:48:25 +1000 Subject: [PATCH 13/40] test --- test | 1 + 1 file changed, 1 insertion(+) create mode 100644 test diff --git a/test b/test new file mode 100644 index 00000000..ff57e617 --- /dev/null +++ b/test @@ -0,0 +1 @@ +testr From 33ea8ba257592153669a3eb08f76db30fb498451 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 15:53:56 +1000 Subject: [PATCH 14/40] fix --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 1621c5ba..73677c81 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -39,6 +39,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF#refs/tags} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${{GITHUB_REF#refs/tags}} push: true From 04943b6d7937b1340778ca580865b6eeb228d4b0 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:04:11 +1000 Subject: [PATCH 15/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 73677c81..bb5de47d 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -39,6 +39,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${{GITHUB_REF#refs/tags}} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ steps.docker-tag.outputs.tag }} push: true From d9b4b1e5e5dbb88e9e60be1962ed55040896bd16 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:06:32 +1000 Subject: [PATCH 16/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index bb5de47d..2ce86bc7 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -39,6 +39,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ steps.docker-tag.outputs.tag }} + tags: ${GITHUB_REF#refs/tags} push: true From 5203d67bc129010619d29f7a7ee1a976413bdb70 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:09:39 +1000 Subject: [PATCH 17/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 2ce86bc7..1621c5ba 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -39,6 +39,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${GITHUB_REF#refs/tags} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF#refs/tags} push: true From af83fbbbd49463ef62d69f7eeb8d963a71a20f0c Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:17:21 +1000 Subject: [PATCH 18/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 1621c5ba..af1f3223 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -39,6 +39,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF#refs/tags} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF/refs/tags//} push: true From b0eedc346810e2d9e3def02e3cd4aef4910ea009 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:20:52 +1000 Subject: [PATCH 19/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index af1f3223..346eac28 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -39,6 +39,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF/refs/tags//} + tags: ${{ secrets.ACR_NAME }}/contoso-website:'${GITHUB_REF/refs\/tags\//}' push: true From dd0510f75713fdb7517a8967bff8429b585dd23d Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:26:05 +1000 Subject: [PATCH 20/40] Update build-production.yml --- .github/workflows/build-production.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 346eac28..6c3cf59b 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -21,7 +21,15 @@ jobs: # You may pin to the exact commit or the version. # uses: docker/setup-buildx-action@0d135e0c2fc0dba0729c1a47ecfcf5a3c7f8579e uses: docker/setup-buildx-action@v1.3.0 - + - name: Build and push the tagged build to production + id: gen_tags + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + TAGS='["user/image:latest","'${GITHUB_REF/refs\/tags\//}'"]' + else + TAGS='["user/image:latest"]' + fi + echo '::set-output name=tags::'$TAGS # Runs a single command using the runners shell - name: Docker Login # You may pin to the exact commit or the version. @@ -39,6 +47,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:'${GITHUB_REF/refs\/tags\//}' + tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ fromJson(steps.gen_tags.outputs.tags) }} push: true From 4bcbe7859c0de15466ed40b2f2de1cf7b452e9a4 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:33:11 +1000 Subject: [PATCH 21/40] Update build-production.yml --- .github/workflows/build-production.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 6c3cf59b..57a7839a 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -24,10 +24,7 @@ jobs: - name: Build and push the tagged build to production id: gen_tags run: | - if [[ $GITHUB_REF == 'refs/tags/'* ]]; then - TAGS='["user/image:latest","'${GITHUB_REF/refs\/tags\//}'"]' - else - TAGS='["user/image:latest"]' + TAGS='${GITHUB_REF/refs\/tags\//}' fi echo '::set-output name=tags::'$TAGS # Runs a single command using the runners shell From e2d891663fd803ced65ca64037f707999c59803a Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:38:01 +1000 Subject: [PATCH 22/40] Update build-production.yml --- .github/workflows/build-production.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 57a7839a..8e71dea1 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -25,7 +25,6 @@ jobs: id: gen_tags run: | TAGS='${GITHUB_REF/refs\/tags\//}' - fi echo '::set-output name=tags::'$TAGS # Runs a single command using the runners shell - name: Docker Login From b976416bb672a37f6ce9baa3c64d32cb3a723501 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:40:36 +1000 Subject: [PATCH 23/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 8e71dea1..9bb07902 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -24,7 +24,7 @@ jobs: - name: Build and push the tagged build to production id: gen_tags run: | - TAGS='${GITHUB_REF/refs\/tags\//}' + TAGS=${GITHUB_REF/refs\/tags\//} echo '::set-output name=tags::'$TAGS # Runs a single command using the runners shell - name: Docker Login From 0a3c5e88a55466b143fb6d3c9679b49b5d451e2a Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:43:05 +1000 Subject: [PATCH 24/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 9bb07902..9273dd91 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -24,7 +24,7 @@ jobs: - name: Build and push the tagged build to production id: gen_tags run: | - TAGS=${GITHUB_REF/refs\/tags\//} + TAGS=${GITHUB_REF#refs/tags} echo '::set-output name=tags::'$TAGS # Runs a single command using the runners shell - name: Docker Login From 970edc62b46eb5206e8a2dd3836b037ace306483 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:44:51 +1000 Subject: [PATCH 25/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 9273dd91..7863fbf0 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -24,7 +24,7 @@ jobs: - name: Build and push the tagged build to production id: gen_tags run: | - TAGS=${GITHUB_REF#refs/tags} + TAGS=${GITHUB_REF/refs/tags} echo '::set-output name=tags::'$TAGS # Runs a single command using the runners shell - name: Docker Login From da5bcd42cce87e9aab47890a46144de681672d22 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:47:36 +1000 Subject: [PATCH 26/40] Update build-production.yml --- .github/workflows/build-production.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 7863fbf0..eec1f9dd 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -21,11 +21,6 @@ jobs: # You may pin to the exact commit or the version. # uses: docker/setup-buildx-action@0d135e0c2fc0dba0729c1a47ecfcf5a3c7f8579e uses: docker/setup-buildx-action@v1.3.0 - - name: Build and push the tagged build to production - id: gen_tags - run: | - TAGS=${GITHUB_REF/refs/tags} - echo '::set-output name=tags::'$TAGS # Runs a single command using the runners shell - name: Docker Login # You may pin to the exact commit or the version. @@ -43,6 +38,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ fromJson(steps.gen_tags.outputs.tags) }} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF/refs/tags} push: true From c2d9a9022c121767e261ca1a532c51ef2fa09ed1 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 20:13:39 +1000 Subject: [PATCH 27/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index eec1f9dd..9dee7bc4 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -38,6 +38,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF/refs/tags} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${{github.ref}} push: true From 2c4837276f87d37395dd1925d68acc5a954e3208 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 20:23:44 +1000 Subject: [PATCH 28/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 9dee7bc4..0afd9712 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -38,6 +38,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${{github.ref}} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${{github.ref.tags}} push: true From 24c5932b0f959eb1bce45e380e2fbe1acc95ea6e Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 20:26:37 +1000 Subject: [PATCH 29/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 0afd9712..f7269c44 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -38,6 +38,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${{github.ref.tags}} + tags: ${{ secrets.ACR_NAME }}/contoso-website:$GITHUB_REF push: true From d67981d463f82dd6f735b703108dd0e35a87266a Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 20:33:51 +1000 Subject: [PATCH 30/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index f7269c44..78f61d09 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -38,6 +38,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:$GITHUB_REF + tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ env.GITHUB_REF }} push: true From 9f8754150538a299e69afd7d0cf85809ddf2a227 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 20:44:14 +1000 Subject: [PATCH 31/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 78f61d09..69d7f853 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -38,6 +38,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ env.GITHUB_REF }} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF##*/} push: true From 7ecaab9fef735edca7688d4a838fc9e0d3ec2103 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 20:52:21 +1000 Subject: [PATCH 32/40] Update build-production.yml --- .github/workflows/build-production.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 69d7f853..209d53e5 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -31,13 +31,15 @@ jobs: username: ${{ secrets.ACR_LOGIN }} password: ${{ secrets.ACR_PASSWORD }} - + - name: Create Tag + run: | + echo '::set-output name=tags::${GITHUB_REF/refs\/tags\//}' - name: Build and push Docker images # You may pin to the exact commit or the version. # uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${GITHUB_REF##*/} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${{steps.gen_tags.outputs.tags}} push: true From f485790c32f58234d6059869d8e7b6178a6e9a33 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 20:54:37 +1000 Subject: [PATCH 33/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 209d53e5..751ebb34 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -40,6 +40,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${{steps.gen_tags.outputs.tags}} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ fromJson(steps.gen_tags.outputs.tags) }} push: true From 9d1fdf6df9ae04b7ec08936312abb50b79e1e94a Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 20:58:23 +1000 Subject: [PATCH 34/40] Update build-production.yml --- .github/workflows/build-production.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 751ebb34..84a128ff 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -32,6 +32,7 @@ jobs: password: ${{ secrets.ACR_PASSWORD }} - name: Create Tag + id: gen_tags run: | echo '::set-output name=tags::${GITHUB_REF/refs\/tags\//}' - name: Build and push Docker images @@ -40,6 +41,6 @@ jobs: uses: docker/build-push-action@v2.5.0 with: context: . - tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ fromJson(steps.gen_tags.outputs.tags) }} + tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ steps.gen_tags.outputs.tags }} push: true From 81b586c5aea9de1b56236afe9cb88eb9f1042277 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Tue, 15 Jun 2021 21:02:09 +1000 Subject: [PATCH 35/40] Update build-production.yml --- .github/workflows/build-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 84a128ff..e0871364 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -34,7 +34,7 @@ jobs: - name: Create Tag id: gen_tags run: | - echo '::set-output name=tags::${GITHUB_REF/refs\/tags\//}' + echo '::set-output name=tags::'"${GITHUB_REF/refs\/tags\//}" - name: Build and push Docker images # You may pin to the exact commit or the version. # uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc From c2afd1d261a5675e7c4bb3b0f0dcc45d0128fd20 Mon Sep 17 00:00:00 2001 From: avikalbajpai Date: Wed, 16 Jun 2021 00:16:30 +0000 Subject: [PATCH 36/40] added helm --- kubernetes/contoso-website/.helmignore | 23 +++++++++++++++++++ kubernetes/contoso-website/Chart.yaml | 4 ++++ .../templates}/deployment.yaml | 3 ++- .../templates}/ingress.yaml | 3 ++- .../templates}/service.yaml | 1 + kubernetes/contoso-website/values.yaml | 7 ++++++ 6 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 kubernetes/contoso-website/.helmignore create mode 100644 kubernetes/contoso-website/Chart.yaml rename kubernetes/{ => contoso-website/templates}/deployment.yaml (74%) rename kubernetes/{ => contoso-website/templates}/ingress.yaml (68%) rename kubernetes/{ => contoso-website/templates}/service.yaml (78%) create mode 100644 kubernetes/contoso-website/values.yaml diff --git a/kubernetes/contoso-website/.helmignore b/kubernetes/contoso-website/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/kubernetes/contoso-website/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/kubernetes/contoso-website/Chart.yaml b/kubernetes/contoso-website/Chart.yaml new file mode 100644 index 00000000..29dcab4c --- /dev/null +++ b/kubernetes/contoso-website/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +name: contoso-website +description: Chart for the Contoso company website +version: 0.1.0 \ No newline at end of file diff --git a/kubernetes/deployment.yaml b/kubernetes/contoso-website/templates/deployment.yaml similarity index 74% rename from kubernetes/deployment.yaml rename to kubernetes/contoso-website/templates/deployment.yaml index 88ad20db..97f336de 100644 --- a/kubernetes/deployment.yaml +++ b/kubernetes/contoso-website/templates/deployment.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: contoso-website + namespace: {{ default "staging" .Release.Namespace }} spec: selector: matchLabels: @@ -12,7 +13,7 @@ spec: app: contoso-website spec: containers: - - image: !IMAGE! + - image: {{ .Values.image.registry }}/{{ .Values.image.name }}:{{ default "latest" .Values.image.tag }} name: contoso-website resources: requests: diff --git a/kubernetes/ingress.yaml b/kubernetes/contoso-website/templates/ingress.yaml similarity index 68% rename from kubernetes/ingress.yaml rename to kubernetes/contoso-website/templates/ingress.yaml index 777d3756..faa3b5b7 100644 --- a/kubernetes/ingress.yaml +++ b/kubernetes/contoso-website/templates/ingress.yaml @@ -2,11 +2,12 @@ apiVersion: extensions/v1beta1 kind: Ingress metadata: name: contoso-website + namespace: {{ default "staging" .Release.Namespace }} annotations: kubernetes.io/ingress.class: addon-http-application-routing spec: rules: - - host: contoso.!DNS! + - host: contoso-{{ default "staging" .Release.Namespace }}.{{ .Values.dns.name }} http: paths: - backend: diff --git a/kubernetes/service.yaml b/kubernetes/contoso-website/templates/service.yaml similarity index 78% rename from kubernetes/service.yaml rename to kubernetes/contoso-website/templates/service.yaml index a0d46d66..23430fac 100644 --- a/kubernetes/service.yaml +++ b/kubernetes/contoso-website/templates/service.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: contoso-website + namespace: {{ default "staging" .Release.Namespace }} spec: ports: - port: 80 diff --git a/kubernetes/contoso-website/values.yaml b/kubernetes/contoso-website/values.yaml new file mode 100644 index 00000000..245350f9 --- /dev/null +++ b/kubernetes/contoso-website/values.yaml @@ -0,0 +1,7 @@ +image: + registry: contosocontainerregistry32723.azurecr.io + name: contoso-website + tag: latest + +dns: + name: ebcabb15a8b447c2b70f.eastus.aksapp.io \ No newline at end of file From c3ba922f05a7bf1559d50472f82d11de661b9603 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Wed, 16 Jun 2021 13:26:42 +1000 Subject: [PATCH 37/40] Create build steps for staging --- .github/workflows/build-staging.yml | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index 964b139f..ee15bd89 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -27,3 +27,37 @@ jobs: context: . tags: ${{ secrets.ACR_NAME }}/contoso-website:latest push: true + + deploy: + runs-on: ubuntu-latest + needs: build_push_image + steps: + - uses: actions/checkout@v2.3.4 + + - name: Install Helm + uses: Azure/setup-helm@v1 + with: + version: v3.3.1 + + - name: Azure Kubernetes set context + uses: Azure/aks-set-context@v1.1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + resource-group: mslearn-gh-pipelines-22922 + cluster-name: contoso-video + + # ... File omitted + - name: Run Helm Deploy + run: | + helm upgrade \ + --install \ + --create-namespace \ + --atomic \ + --wait \ + --namespace staging \ + contoso-website \ + ./kubernetes/contoso-website \ + --set image.repository=${{ secrets.ACR_NAME }} \ + --set dns.name=${{ secrets.DNS_NAME }} + + From de319343fe4ebcf9424ccfc2bc5e55dd10a7b3bb Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Wed, 16 Jun 2021 13:53:07 +1000 Subject: [PATCH 38/40] Creating first production deployment --- .github/workflows/build-production.yml | 36 +++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index e0871364..bc828a96 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -8,7 +8,7 @@ on: # 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: + build_push_image: # The type of runner that the job will run on runs-on: ubuntu-latest @@ -43,4 +43,38 @@ jobs: context: . tags: ${{ secrets.ACR_NAME }}/contoso-website:${{ steps.gen_tags.outputs.tags }} push: true + + deploy: + runs-on: ubuntu-latest + needs: build_push_image + steps: + - uses: actions/checkout@v2.3.4 + + - name: Install Helm + uses: Azure/setup-helm@v1 + with: + version: v3.3.1 + + - name: Azure Kubernetes set context + uses: Azure/aks-set-context@v1.1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + resource-group: mslearn-gh-pipelines-22922 + cluster-name: contoso-video + + # ... File omitted + - name: Run Helm Deploy + run: | + helm upgrade \ + --install \ + --create-namespace \ + --atomic \ + --wait \ + --namespace production \ + contoso-website \ + ./kubernetes/contoso-website \ + --set image.repository=${{ secrets.ACR_NAME }} \ + --set dns.name=${{ secrets.DNS_NAME }} \ + --set image.tag=${GITHUB_REF##*/} + From 52f578fea3b9e29fa66b6516a729dc2cf49739a9 Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Wed, 16 Jun 2021 14:00:55 +1000 Subject: [PATCH 39/40] Update build-production.yml --- .github/workflows/build-production.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index bc828a96..73c4ad5a 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -62,6 +62,10 @@ jobs: resource-group: mslearn-gh-pipelines-22922 cluster-name: contoso-video + - name: Create Tag + id: gen_tags + run: | + echo '::set-output name=tags::'"${GITHUB_REF/refs\/tags\//}" # ... File omitted - name: Run Helm Deploy run: | @@ -75,6 +79,6 @@ jobs: ./kubernetes/contoso-website \ --set image.repository=${{ secrets.ACR_NAME }} \ --set dns.name=${{ secrets.DNS_NAME }} \ - --set image.tag=${GITHUB_REF##*/} + --set image.tag=${{ steps.gen_tags.outputs.tags }} From 4268b27e3882df9c53506c12a56d720073ad6b4d Mon Sep 17 00:00:00 2001 From: Avikal Bajpai <82566209+avikalbajpai@users.noreply.github.com> Date: Wed, 16 Jun 2021 14:06:21 +1000 Subject: [PATCH 40/40] Update build-production.yml --- .github/workflows/build-production.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml index 73c4ad5a..9da7548c 100644 --- a/.github/workflows/build-production.yml +++ b/.github/workflows/build-production.yml @@ -62,11 +62,7 @@ jobs: resource-group: mslearn-gh-pipelines-22922 cluster-name: contoso-video - - name: Create Tag - id: gen_tags - run: | - echo '::set-output name=tags::'"${GITHUB_REF/refs\/tags\//}" - # ... File omitted + # ... File omitted - name: Run Helm Deploy run: | helm upgrade \ @@ -79,6 +75,6 @@ jobs: ./kubernetes/contoso-website \ --set image.repository=${{ secrets.ACR_NAME }} \ --set dns.name=${{ secrets.DNS_NAME }} \ - --set image.tag=${{ steps.gen_tags.outputs.tags }} + --set image.tag=${GITHUB_REF##*/}