From 5b2987f956baeef3064bc103a10f5b6e58fa7cc4 Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Fri, 2 Dec 2022 19:14:35 -0500 Subject: [PATCH 1/5] docker build gha init --- .github/dependabot.yml | 7 ++ .../workflows/call-docker-build-result.yaml | 83 +++++++++++++++++++ .github/workflows/call-docker-build-vote.yaml | 83 +++++++++++++++++++ .../workflows/call-docker-build-worker.yaml | 83 +++++++++++++++++++ 4 files changed, 256 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/call-docker-build-result.yaml create mode 100644 .github/workflows/call-docker-build-vote.yaml create mode 100644 .github/workflows/call-docker-build-worker.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f9ecf57 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/call-docker-build-result.yaml b/.github/workflows/call-docker-build-result.yaml new file mode 100644 index 0000000..71201bd --- /dev/null +++ b/.github/workflows/call-docker-build-result.yaml @@ -0,0 +1,83 @@ +name: Build Result +# template source: https://github.com/dockersamples/.github/blob/main/templates/call-docker-build.yaml + +on: + # we want pull requests so we can build(test) but not push to image registry + push: + branches: + - 'main' + # only build when important files change + paths: + - 'result/**' + - '.github/workflows/call-docker-build-result.yaml' + pull_request: + branches: + - 'main' + # only build when important files change + paths: + - 'result/**' + - '.github/workflows/call-docker-build-result.yaml' + +jobs: + call-docker-build: + + name: Call Docker Build + + uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@gha-reusable-init + + permissions: + contents: read + packages: write # needed to push docker image to ghcr.io + pull-requests: write # needed to create and update comments in PRs + + secrets: + + # Only needed if with:dockerhub-enable is true below + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + + # Only needed if with:dockerhub-enable is true below + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} + + with: + + ### REQUIRED + ### ENABLE ONE OR BOTH REGISTRIES + ### tell docker where to push. + ### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below + dockerhub-enable: false + ghcr-enable: true + + ### REQUIRED + ### A list of the account/repo names for docker build. List should match what's enabled above + ### defaults to: + image-names: | + dockersamples/examplevotingapp_result + ghcr.io/dockersamples/example-voting-app-result + + ### REQUIRED set rules for tagging images, based on special action syntax: + ### https://github.com/docker/metadata-action#tags-input + ### defaults to: + tag-rules: | + type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} + type=ref,event=pr + type=ref,event=branch + type=semver,pattern={{version}} + type=raw,value=gha-${{ github.run_id }} + + ### path to where docker should copy files into image + ### defaults to root of repository (.) + context: result + + ### Dockerfile alternate name. Default is Dockerfile (relative to context path) + # file: Containerfile + + ### build stage to target, defaults to empty, which builds to last stage in Dockerfile + # target: + + ### platforms to build for, defaults to linux/amd64 + ### other options: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/arm/v7 + + ### Create a PR comment with image tags and labels + ### defaults to false + # comment-enable: false diff --git a/.github/workflows/call-docker-build-vote.yaml b/.github/workflows/call-docker-build-vote.yaml new file mode 100644 index 0000000..d47c499 --- /dev/null +++ b/.github/workflows/call-docker-build-vote.yaml @@ -0,0 +1,83 @@ +name: Build Vote +# template source: https://github.com/dockersamples/.github/blob/main/templates/call-docker-build.yaml + +on: + # we want pull requests so we can build(test) but not push to image registry + push: + branches: + - 'main' + # only build when important files change + paths: + - 'vote/**' + - '.github/workflows/call-docker-build-vote.yaml' + pull_request: + branches: + - 'main' + # only build when important files change + paths: + - 'vote/**' + - '.github/workflows/call-docker-build-vote.yaml' + +jobs: + call-docker-build: + + name: Call Docker Build + + uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@gha-reusable-init + + permissions: + contents: read + packages: write # needed to push docker image to ghcr.io + pull-requests: write # needed to create and update comments in PRs + + secrets: + + # Only needed if with:dockerhub-enable is true below + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + + # Only needed if with:dockerhub-enable is true below + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} + + with: + + ### REQUIRED + ### ENABLE ONE OR BOTH REGISTRIES + ### tell docker where to push. + ### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below + dockerhub-enable: false + ghcr-enable: true + + ### REQUIRED + ### A list of the account/repo names for docker build. List should match what's enabled above + ### defaults to: + image-names: | + dockersamples/examplevotingapp_vote + ghcr.io/dockersamples/example-voting-app-vote + + ### REQUIRED set rules for tagging images, based on special action syntax: + ### https://github.com/docker/metadata-action#tags-input + ### defaults to: + # tag-rules: | + # type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} + # type=ref,event=pr + # type=ref,event=branch + # type=semver,pattern={{version}} + # type=raw,value=gha-${{ github.run_id }} + + ### path to where docker should copy files into image + ### defaults to root of repository (.) + context: vote + + ### Dockerfile alternate name. Default is Dockerfile (relative to context path) + # file: Containerfile + + ### build stage to target, defaults to empty, which builds to last stage in Dockerfile + # target: + + ### platforms to build for, defaults to linux/amd64 + ### other options: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/arm/v7 + + ### Create a PR comment with image tags and labels + ### defaults to false + # comment-enable: false diff --git a/.github/workflows/call-docker-build-worker.yaml b/.github/workflows/call-docker-build-worker.yaml new file mode 100644 index 0000000..8937884 --- /dev/null +++ b/.github/workflows/call-docker-build-worker.yaml @@ -0,0 +1,83 @@ +name: Build Worker +# template source: https://github.com/dockersamples/.github/blob/main/templates/call-docker-build.yaml + +on: + # we want pull requests so we can build(test) but not push to image registry + push: + branches: + - 'main' + # only build when important files change + paths: + - 'worker/**' + - '.github/workflows/call-docker-build-worker.yaml' + pull_request: + branches: + - 'main' + # only build when important files change + paths: + - 'worker/**' + - '.github/workflows/call-docker-build-worker.yaml' + +jobs: + call-docker-build: + + name: Call Docker Build + + uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@gha-reusable-init + + permissions: + contents: read + packages: write # needed to push docker image to ghcr.io + pull-requests: write # needed to create and update comments in PRs + + secrets: + + # Only needed if with:dockerhub-enable is true below + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + + # Only needed if with:dockerhub-enable is true below + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} + + with: + + ### REQUIRED + ### ENABLE ONE OR BOTH REGISTRIES + ### tell docker where to push. + ### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below + dockerhub-enable: false + ghcr-enable: true + + ### REQUIRED + ### A list of the account/repo names for docker build. List should match what's enabled above + ### defaults to: + image-names: | + dockersamples/examplevotingapp_worker + ghcr.io/dockersamples/example-voting-app-worker + + ### REQUIRED set rules for tagging images, based on special action syntax: + ### https://github.com/docker/metadata-action#tags-input + ### defaults to: + # tag-rules: | + # type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} + # type=ref,event=pr + # type=ref,event=branch + # type=semver,pattern={{version}} + # type=raw,value=gha-${{ github.run_id }} + + ### path to where docker should copy files into image + ### defaults to root of repository (.) + context: worker + + ### Dockerfile alternate name. Default is Dockerfile (relative to context path) + # file: Containerfile + + ### build stage to target, defaults to empty, which builds to last stage in Dockerfile + # target: + + ### platforms to build for, defaults to linux/amd64 + ### other options: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/arm/v7 + + ### Create a PR comment with image tags and labels + ### defaults to false + # comment-enable: false From 91640194906e7015249b1f8af34c4625a1812c34 Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Sat, 3 Dec 2022 09:15:52 -0500 Subject: [PATCH 2/5] disable Hub until bot account works --- .github/workflows/call-docker-build-result.yaml | 4 ++-- .github/workflows/call-docker-build-vote.yaml | 4 ++-- .github/workflows/call-docker-build-worker.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/call-docker-build-result.yaml b/.github/workflows/call-docker-build-result.yaml index 71201bd..442bff8 100644 --- a/.github/workflows/call-docker-build-result.yaml +++ b/.github/workflows/call-docker-build-result.yaml @@ -51,9 +51,9 @@ jobs: ### A list of the account/repo names for docker build. List should match what's enabled above ### defaults to: image-names: | - dockersamples/examplevotingapp_result ghcr.io/dockersamples/example-voting-app-result - + # dockersamples/examplevotingapp_result + ### REQUIRED set rules for tagging images, based on special action syntax: ### https://github.com/docker/metadata-action#tags-input ### defaults to: diff --git a/.github/workflows/call-docker-build-vote.yaml b/.github/workflows/call-docker-build-vote.yaml index d47c499..f8964b0 100644 --- a/.github/workflows/call-docker-build-vote.yaml +++ b/.github/workflows/call-docker-build-vote.yaml @@ -51,9 +51,9 @@ jobs: ### A list of the account/repo names for docker build. List should match what's enabled above ### defaults to: image-names: | - dockersamples/examplevotingapp_vote ghcr.io/dockersamples/example-voting-app-vote - + # dockersamples/examplevotingapp_vote + ### REQUIRED set rules for tagging images, based on special action syntax: ### https://github.com/docker/metadata-action#tags-input ### defaults to: diff --git a/.github/workflows/call-docker-build-worker.yaml b/.github/workflows/call-docker-build-worker.yaml index 8937884..4f8f2ac 100644 --- a/.github/workflows/call-docker-build-worker.yaml +++ b/.github/workflows/call-docker-build-worker.yaml @@ -51,9 +51,9 @@ jobs: ### A list of the account/repo names for docker build. List should match what's enabled above ### defaults to: image-names: | - dockersamples/examplevotingapp_worker ghcr.io/dockersamples/example-voting-app-worker - + # dockersamples/examplevotingapp_worker + ### REQUIRED set rules for tagging images, based on special action syntax: ### https://github.com/docker/metadata-action#tags-input ### defaults to: From 88d04ef0854791068deb5f144b862238f5231178 Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Fri, 9 Dec 2022 15:57:14 -0500 Subject: [PATCH 3/5] updating GHA paths --- .github/workflows/call-docker-build-result.yaml | 4 ++-- .github/workflows/call-docker-build-vote.yaml | 4 ++-- .github/workflows/call-docker-build-worker.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/call-docker-build-result.yaml b/.github/workflows/call-docker-build-result.yaml index 442bff8..acc3c21 100644 --- a/.github/workflows/call-docker-build-result.yaml +++ b/.github/workflows/call-docker-build-result.yaml @@ -21,9 +21,9 @@ on: jobs: call-docker-build: - name: Call Docker Build + name: Result Call Docker Build - uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@gha-reusable-init + uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@main permissions: contents: read diff --git a/.github/workflows/call-docker-build-vote.yaml b/.github/workflows/call-docker-build-vote.yaml index f8964b0..af8dbe7 100644 --- a/.github/workflows/call-docker-build-vote.yaml +++ b/.github/workflows/call-docker-build-vote.yaml @@ -21,9 +21,9 @@ on: jobs: call-docker-build: - name: Call Docker Build + name: Vote Call Docker Build - uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@gha-reusable-init + uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@main permissions: contents: read diff --git a/.github/workflows/call-docker-build-worker.yaml b/.github/workflows/call-docker-build-worker.yaml index 4f8f2ac..94cce54 100644 --- a/.github/workflows/call-docker-build-worker.yaml +++ b/.github/workflows/call-docker-build-worker.yaml @@ -21,9 +21,9 @@ on: jobs: call-docker-build: - name: Call Docker Build + name: Worker Call Docker Build - uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@gha-reusable-init + uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@main permissions: contents: read From 6f953ce289161eac95d0ad24761d66edcf24aa49 Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Fri, 9 Dec 2022 16:18:40 -0500 Subject: [PATCH 4/5] enable docker hub --- .github/workflows/call-docker-build-result.yaml | 2 +- .github/workflows/call-docker-build-vote.yaml | 2 +- .github/workflows/call-docker-build-worker.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/call-docker-build-result.yaml b/.github/workflows/call-docker-build-result.yaml index acc3c21..a869ecd 100644 --- a/.github/workflows/call-docker-build-result.yaml +++ b/.github/workflows/call-docker-build-result.yaml @@ -44,7 +44,7 @@ jobs: ### ENABLE ONE OR BOTH REGISTRIES ### tell docker where to push. ### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below - dockerhub-enable: false + dockerhub-enable: true ghcr-enable: true ### REQUIRED diff --git a/.github/workflows/call-docker-build-vote.yaml b/.github/workflows/call-docker-build-vote.yaml index af8dbe7..3c8f57f 100644 --- a/.github/workflows/call-docker-build-vote.yaml +++ b/.github/workflows/call-docker-build-vote.yaml @@ -44,7 +44,7 @@ jobs: ### ENABLE ONE OR BOTH REGISTRIES ### tell docker where to push. ### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below - dockerhub-enable: false + dockerhub-enable: true ghcr-enable: true ### REQUIRED diff --git a/.github/workflows/call-docker-build-worker.yaml b/.github/workflows/call-docker-build-worker.yaml index 94cce54..2c5f9f9 100644 --- a/.github/workflows/call-docker-build-worker.yaml +++ b/.github/workflows/call-docker-build-worker.yaml @@ -44,7 +44,7 @@ jobs: ### ENABLE ONE OR BOTH REGISTRIES ### tell docker where to push. ### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below - dockerhub-enable: false + dockerhub-enable: true ghcr-enable: true ### REQUIRED From 5a23ae2245a040a91b2131156dd17df6b8dece9d Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Fri, 9 Dec 2022 16:47:00 -0500 Subject: [PATCH 5/5] disable worker arm/v7 support for now --- .github/workflows/call-docker-build-worker.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/call-docker-build-worker.yaml b/.github/workflows/call-docker-build-worker.yaml index 2c5f9f9..c10d9c6 100644 --- a/.github/workflows/call-docker-build-worker.yaml +++ b/.github/workflows/call-docker-build-worker.yaml @@ -76,7 +76,9 @@ jobs: ### platforms to build for, defaults to linux/amd64 ### other options: linux/amd64,linux/arm64,linux/arm/v7 - platforms: linux/amd64,linux/arm64,linux/arm/v7 + # FIXME worker arm/v7 support doesn't build in .net core 3.1 with QEMU + # a fix would likely run the .net build on amd64 but with a target of arm/v7 + platforms: linux/amd64,linux/arm64 ### Create a PR comment with image tags and labels ### defaults to false