From 74f1c58379439dc3f2667dd0e41ce79217166b54 Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 15:56:10 -0400 Subject: [PATCH 01/18] chore: add workflow to build and push image --- .github/workflows/build.yml | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..159c05ff --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Build +on: + push: + branches: [develop, main, 731-create-build-and-push-workflow] + pull_request: + branches: [develop, main, 731-create-build-and-push-workflow] +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push api + uses: docker/build-push-action@v4 + with: + push: true + tags: user/app:latest + file: {context}/api/Dockerfile + - + name: Build and push app + uses: docker/build-push-action@v4 + with: + push: true + tags: user/app:latest + file: {context}/app/Dockerfile + - + name: Build and push real_fake_sensors + uses: docker/build-push-action@v4 + with: + push: true + tags: user/app:latest + file: {context}/real_fake_sensors/Dockerfile + - + name: Build and push sensational_sensors + uses: docker/build-push-action@v4 + with: + push: true + tags: user/app:latest + file: {context}/sensational_sensors/Dockerfile \ No newline at end of file From 4e4073ada8786e8b3703151fa8bb20daef335102 Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 16:09:50 -0400 Subject: [PATCH 02/18] chore: fix syntax error --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 159c05ff..6ea4c9cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,25 +26,25 @@ jobs: with: push: true tags: user/app:latest - file: {context}/api/Dockerfile + file: api/Dockerfile - name: Build and push app uses: docker/build-push-action@v4 with: push: true tags: user/app:latest - file: {context}/app/Dockerfile + file: app/Dockerfile - name: Build and push real_fake_sensors uses: docker/build-push-action@v4 with: push: true tags: user/app:latest - file: {context}/real_fake_sensors/Dockerfile + file: real_fake_sensors/Dockerfile - name: Build and push sensational_sensors uses: docker/build-push-action@v4 with: push: true tags: user/app:latest - file: {context}/sensational_sensors/Dockerfile \ No newline at end of file + file: sensational_sensors/Dockerfile \ No newline at end of file From 8befd08550e25ec1aaed41e877fe20dc7ab20a32 Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 16:43:03 -0400 Subject: [PATCH 03/18] chore: switch to GHCR --- .github/workflows/build.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ea4c9cb..8edfcd96 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,36 +15,37 @@ jobs: name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub + name: Login to GHCR uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: ghcr.io + username: ${{ secrets.GHCR_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} - name: Build and push api uses: docker/build-push-action@v4 with: push: true - tags: user/app:latest + tags: ghcr.io/user/app:latest file: api/Dockerfile - name: Build and push app uses: docker/build-push-action@v4 with: push: true - tags: user/app:latest + tags: ghcr.io/user/app:latest file: app/Dockerfile - name: Build and push real_fake_sensors uses: docker/build-push-action@v4 with: push: true - tags: user/app:latest + tags: ghcr.io/user/app:latest file: real_fake_sensors/Dockerfile - name: Build and push sensational_sensors uses: docker/build-push-action@v4 with: push: true - tags: user/app:latest + tags: ghcr.io/user/app:latest file: sensational_sensors/Dockerfile \ No newline at end of file From ecae13590e3671f409833aa7f8cfc499be198f4f Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 17:21:41 -0400 Subject: [PATCH 04/18] chore: add permissions to workflow --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8edfcd96..e3ff4d18 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,9 @@ on: jobs: docker: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Set up QEMU From 9066c8d31b4ec9b83a25416e4d08c0c289469948 Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 17:27:14 -0400 Subject: [PATCH 05/18] chore: change version of login action --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e3ff4d18..fb6e638c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to GHCR - uses: docker/login-action@v2 + uses: docker/login-action@v1.10.0 with: registry: ghcr.io username: ${{ secrets.GHCR_USERNAME }} From d3d5d2f6e049d614d3552baec5c79e82291d586a Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 17:43:30 -0400 Subject: [PATCH 06/18] chore: just try login --- .github/workflows/build.yml | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb6e638c..f395cf51 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,36 +19,9 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to GHCR - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ secrets.GHCR_USERNAME }} password: ${{ secrets.GHCR_TOKEN }} - - - name: Build and push api - uses: docker/build-push-action@v4 - with: - push: true - tags: ghcr.io/user/app:latest - file: api/Dockerfile - - - name: Build and push app - uses: docker/build-push-action@v4 - with: - push: true - tags: ghcr.io/user/app:latest - file: app/Dockerfile - - - name: Build and push real_fake_sensors - uses: docker/build-push-action@v4 - with: - push: true - tags: ghcr.io/user/app:latest - file: real_fake_sensors/Dockerfile - - - name: Build and push sensational_sensors - uses: docker/build-push-action@v4 - with: - push: true - tags: ghcr.io/user/app:latest - file: sensational_sensors/Dockerfile \ No newline at end of file + \ No newline at end of file From 09ce058ebf67a4b7d716ec8e8e0fb9d940e0a53a Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 17:46:56 -0400 Subject: [PATCH 07/18] chore: add api --- .github/workflows/build.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f395cf51..db93eb6e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,4 +24,12 @@ jobs: registry: ghcr.io username: ${{ secrets.GHCR_USERNAME }} password: ${{ secrets.GHCR_TOKEN }} - \ No newline at end of file + - + name: Build and push api + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ghcr.io/user/api:latest + labels: ${{ steps.meta.outputs.labels }} + file: api/Dockerfile From 5f364f8176ce3360b1fe861a6a2bf65a967a8015 Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 17:52:17 -0400 Subject: [PATCH 08/18] chore: change tag and label --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db93eb6e..8e58475b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,6 @@ jobs: with: context: . push: true - tags: ghcr.io/user/api:latest - labels: ${{ steps.meta.outputs.labels }} + tags: api_tag + labels: api_label file: api/Dockerfile From 239d734d95a27926acc058096fa4eabc818a6d18 Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 17:55:54 -0400 Subject: [PATCH 09/18] chore: use gh actions tutorial --- .github/workflows/build.yml | 45 ++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e58475b..a3fd7bc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,35 +1,44 @@ name: Build + on: push: branches: [develop, main, 731-create-build-and-push-workflow] pull_request: branches: [develop, main, 731-create-build-and-push-workflow] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: - docker: + build-and-push-image: runs-on: ubuntu-latest + permissions: contents: read packages: write + steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to GHCR - uses: docker/login-action@v2 + - name: Checkout repository + uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: - registry: ghcr.io - username: ${{ secrets.GHCR_USERNAME }} - password: ${{ secrets.GHCR_TOKEN }} - - - name: Build and push api + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . push: true - tags: api_tag - labels: api_label - file: api/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + file: api/Dockerfile \ No newline at end of file From dc665e41f2a0733b24b8b03f17261cfbe08d9dda Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 18:05:32 -0400 Subject: [PATCH 10/18] chore: add other dockerfiles --- .github/workflows/build.yml | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3fd7bc9..76aebbab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,11 +34,38 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push Docker image + - name: Build and push api Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - file: api/Dockerfile \ No newline at end of file + file: api/Dockerfile + + - name: Build and push app Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + file: app/Dockerfile + + - name: Build and push real_fake_sensors Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + file: real_fake_sensors/Dockerfile + + - name: Build and push sensational_sensors Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + file: sensational_sensors/Dockerfile \ No newline at end of file From f7c6ec965e1511548ccdd04f060813f00f02c273 Mon Sep 17 00:00:00 2001 From: Ballard Date: Thu, 10 Aug 2023 19:42:23 -0400 Subject: [PATCH 11/18] chore: add name arg --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76aebbab..4401b101 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,6 +37,7 @@ jobs: - name: Build and push api Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: + name: api context: . push: true tags: ${{ steps.meta.outputs.tags }} @@ -46,6 +47,7 @@ jobs: - name: Build and push app Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: + name: app context: . push: true tags: ${{ steps.meta.outputs.tags }} @@ -55,6 +57,7 @@ jobs: - name: Build and push real_fake_sensors Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: + name: real_fake_sensors context: . push: true tags: ${{ steps.meta.outputs.tags }} @@ -64,6 +67,7 @@ jobs: - name: Build and push sensational_sensors Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: + name: sensational_sensors context: . push: true tags: ${{ steps.meta.outputs.tags }} From 7a8404bdbd68e89789a8391148f15b0a021e1c87 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 10 Aug 2023 17:09:11 -0700 Subject: [PATCH 12/18] chore: test a matrix approach to pushing images --- .github/workflows/build-and-push.yml | 82 +++++++++++++++++ .github/workflows/build.yml | 130 +++++++++++++-------------- 2 files changed, 147 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/build-and-push.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 00000000..9ad0c837 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,82 @@ +name: Build and push images + +on: + push: + branches: [develop, main] + pull_request: + branches: [develop, main] + +env: + REGISTRY: ghcr.io + REPO_NAME: ${{ github.repository }} + +jobs: + docker-build: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - image: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/app + context: . + dockerfile: app/Dockerfile + name: app + - image: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/api + context: . + dockerfile: api/Dockerfile + name: api + - image: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/real_fake_sensors + context: . + dockerfile: real_fake_sensors/Dockerfile + name: realFakeSensors + - image: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/sensational_sensors + context: . + dockerfile: sensational_sensors/Dockerfile + name: realFakeSensors + name: Build ${{ matrix.name }} docker image + steps: + - uses: actions/checkout@v3 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + with: + install: true + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ matrix.image }} + tags: | + type=sha,format=long,prefix= + latest + type=ref,event=pr + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ matrix.name }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-${{ matrix.name }} + - name: Build image + uses: docker/build-push-action@v3 + with: + context: ${{ matrix.context }} + builder: ${{ steps.buildx.outputs.name }} + push: true + file: ${{ matrix.dockerfile }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4401b101..2b990850 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,75 +1,75 @@ -name: Build +# name: Build -on: - push: - branches: [develop, main, 731-create-build-and-push-workflow] - pull_request: - branches: [develop, main, 731-create-build-and-push-workflow] +# on: +# push: +# branches: [develop, main, 731-create-build-and-push-workflow] +# pull_request: +# branches: [develop, main, 731-create-build-and-push-workflow] -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} +# env: +# REGISTRY: ghcr.io +# IMAGE_NAME: ${{ github.repository }} -jobs: - build-and-push-image: - runs-on: ubuntu-latest +# jobs: +# build-and-push-image: +# runs-on: ubuntu-latest - permissions: - contents: read - packages: write +# permissions: +# contents: read +# packages: write - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} +# steps: +# - name: Checkout repository +# uses: actions/checkout@v3 +# - name: Log in to the Container registry +# uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 +# with: +# registry: ${{ env.REGISTRY }} +# username: ${{ github.actor }} +# password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} +# - name: Extract metadata (tags, labels) for Docker +# id: meta +# uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 +# with: +# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push api Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - name: api - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - file: api/Dockerfile +# - name: Build and push api Docker image +# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 +# with: +# name: api +# context: . +# push: true +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} +# file: api/Dockerfile - - name: Build and push app Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - name: app - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - file: app/Dockerfile +# - name: Build and push app Docker image +# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 +# with: +# name: app +# context: . +# push: true +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} +# file: app/Dockerfile - - name: Build and push real_fake_sensors Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - name: real_fake_sensors - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - file: real_fake_sensors/Dockerfile +# - name: Build and push real_fake_sensors Docker image +# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 +# with: +# name: real_fake_sensors +# context: . +# push: true +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} +# file: real_fake_sensors/Dockerfile - - name: Build and push sensational_sensors Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - name: sensational_sensors - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - file: sensational_sensors/Dockerfile \ No newline at end of file +# - name: Build and push sensational_sensors Docker image +# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 +# with: +# name: sensational_sensors +# context: . +# push: true +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} +# file: sensational_sensors/Dockerfile From ffb44f3e9f83e79f1dbcdf60a908421ef2e7821e Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 10 Aug 2023 17:12:24 -0700 Subject: [PATCH 13/18] chore: temp run the action on this feature branch to test it --- .github/workflows/build-and-push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 9ad0c837..1b33dba3 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -2,9 +2,9 @@ name: Build and push images on: push: - branches: [develop, main] + branches: [develop, main, 731-create-build-and-push-workflow] pull_request: - branches: [develop, main] + branches: [develop, main, 731-create-build-and-push-workflow] env: REGISTRY: ghcr.io From c42e4c642b7056d5b69b586118bf08b924d8c243 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 10 Aug 2023 17:16:53 -0700 Subject: [PATCH 14/18] chore: hardcode ghcr url --- .github/workflows/build-and-push.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 1b33dba3..b52bf2ab 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -16,19 +16,19 @@ jobs: strategy: matrix: include: - - image: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/app + - image: ghcr.io/button-inc/iot-system-prototype/app context: . dockerfile: app/Dockerfile name: app - - image: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/api + - image: ghcr.io/button-inc/iot-system-prototype/api context: . dockerfile: api/Dockerfile name: api - - image: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/real_fake_sensors + - image: ghcr.io/button-inc/iot-system-prototype/real_fake_sensors context: . dockerfile: real_fake_sensors/Dockerfile name: realFakeSensors - - image: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/sensational_sensors + - image: ghcr.io/button-inc/iot-system-prototype/sensational_sensors context: . dockerfile: sensational_sensors/Dockerfile name: realFakeSensors From b339d9e9d2a05fb5c66f43389f071ef5c3c177bc Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 10 Aug 2023 17:25:05 -0700 Subject: [PATCH 15/18] chore: change github use to actor not owner --- .github/workflows/build-and-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index b52bf2ab..9bd9e0bf 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -53,7 +53,7 @@ jobs: uses: docker/login-action@v2 with: registry: ghcr.io - username: ${{ github.repository_owner }} + username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Cache Docker layers uses: actions/cache@v3 From 1ab7ab754ee66aae57d66e19c9068c74a543901f Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 10 Aug 2023 18:31:50 -0700 Subject: [PATCH 16/18] chore: remove feature branch from the list of branches to run the action on --- .github/workflows/build-and-push.yml | 4 +- .github/workflows/build.yml | 75 ---------------------------- 2 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 9bd9e0bf..c2ebc034 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -2,9 +2,9 @@ name: Build and push images on: push: - branches: [develop, main, 731-create-build-and-push-workflow] + branches: [develop, main] pull_request: - branches: [develop, main, 731-create-build-and-push-workflow] + branches: [develop, main] env: REGISTRY: ghcr.io diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 2b990850..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,75 +0,0 @@ -# name: Build - -# on: -# push: -# branches: [develop, main, 731-create-build-and-push-workflow] -# pull_request: -# branches: [develop, main, 731-create-build-and-push-workflow] - -# env: -# REGISTRY: ghcr.io -# IMAGE_NAME: ${{ github.repository }} - -# jobs: -# build-and-push-image: -# runs-on: ubuntu-latest - -# permissions: -# contents: read -# packages: write - -# steps: -# - name: Checkout repository -# uses: actions/checkout@v3 -# - name: Log in to the Container registry -# uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 -# with: -# registry: ${{ env.REGISTRY }} -# username: ${{ github.actor }} -# password: ${{ secrets.GITHUB_TOKEN }} - -# - name: Extract metadata (tags, labels) for Docker -# id: meta -# uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 -# with: -# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - -# - name: Build and push api Docker image -# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 -# with: -# name: api -# context: . -# push: true -# tags: ${{ steps.meta.outputs.tags }} -# labels: ${{ steps.meta.outputs.labels }} -# file: api/Dockerfile - -# - name: Build and push app Docker image -# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 -# with: -# name: app -# context: . -# push: true -# tags: ${{ steps.meta.outputs.tags }} -# labels: ${{ steps.meta.outputs.labels }} -# file: app/Dockerfile - -# - name: Build and push real_fake_sensors Docker image -# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 -# with: -# name: real_fake_sensors -# context: . -# push: true -# tags: ${{ steps.meta.outputs.tags }} -# labels: ${{ steps.meta.outputs.labels }} -# file: real_fake_sensors/Dockerfile - -# - name: Build and push sensational_sensors Docker image -# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 -# with: -# name: sensational_sensors -# context: . -# push: true -# tags: ${{ steps.meta.outputs.tags }} -# labels: ${{ steps.meta.outputs.labels }} -# file: sensational_sensors/Dockerfile From ae05a63153048668310751953ba082bae089ccef Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 10 Aug 2023 18:40:01 -0700 Subject: [PATCH 17/18] chore: remove unused env and fix name on sensationalSensors --- .github/workflows/build-and-push.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index c2ebc034..867b7614 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -6,10 +6,6 @@ on: pull_request: branches: [develop, main] -env: - REGISTRY: ghcr.io - REPO_NAME: ${{ github.repository }} - jobs: docker-build: runs-on: ubuntu-latest @@ -31,7 +27,7 @@ jobs: - image: ghcr.io/button-inc/iot-system-prototype/sensational_sensors context: . dockerfile: sensational_sensors/Dockerfile - name: realFakeSensors + name: sensationalSensors name: Build ${{ matrix.name }} docker image steps: - uses: actions/checkout@v3 From 3ab03a03933e7ef74a1019dd6782df85a7d783b4 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 10 Aug 2023 18:42:27 -0700 Subject: [PATCH 18/18] chore: temporarily add branch back to list --- .github/workflows/build-and-push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 867b7614..51d7ca92 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -2,9 +2,9 @@ name: Build and push images on: push: - branches: [develop, main] + branches: [develop, main, 731-create-build-and-push-workflow] pull_request: - branches: [develop, main] + branches: [develop, main, 731-create-build-and-push-workflow] jobs: docker-build: