build(ci): remove checkout action for build-push-action

build-push-action uses Git context by default. No need for checkout
action unless you tamper with repo files before build.

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-06-18 15:16:10 +02:00
parent 7c2d3ea17d
commit 4b089c535f
30 changed files with 40 additions and 237 deletions

View File

@ -19,7 +19,7 @@ with [build-push-action] and [bake-action].
{{< tabs >}} {{< tabs >}}
{{< tab name="build-push-action" >}} {{< tab name="build-push-action" >}}
```yaml {hl_lines=35} ```yaml {hl_lines=32}
name: ci name: ci
on: on:
@ -32,9 +32,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -117,7 +114,7 @@ want to annotate. For example, setting `DOCKER_METADATA_ANNOTATIONS_LEVELS` to
The following example creates annotations on both the image index and The following example creates annotations on both the image index and
manifests. manifests.
```yaml {hl_lines=31} ```yaml {hl_lines=28}
name: ci name: ci
on: on:
@ -130,9 +127,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3

View File

@ -62,9 +62,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -83,7 +80,6 @@ jobs:
- name: Build and push image - name: Build and push image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
push: true push: true
provenance: mode=max provenance: mode=max
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
@ -112,9 +108,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -133,7 +126,6 @@ jobs:
- name: Build and push image - name: Build and push image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
sbom: true sbom: true
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}

View File

@ -80,7 +80,6 @@ variable in the YAML configuration for your build step:
env: env:
DOCKER_BUILD_NO_SUMMARY: true DOCKER_BUILD_NO_SUMMARY: true
with: with:
context: .
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
``` ```

View File

@ -28,9 +28,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -43,7 +40,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
push: true push: true
tags: user/app:latest tags: user/app:latest
cache-from: type=registry,ref=user/app:latest cache-from: type=registry,ref=user/app:latest
@ -65,9 +61,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -80,7 +73,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
push: true push: true
tags: user/app:latest tags: user/app:latest
cache-from: type=registry,ref=user/app:buildcache cache-from: type=registry,ref=user/app:buildcache
@ -114,9 +106,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -129,7 +118,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
push: true push: true
tags: user/app:latest tags: user/app:latest
cache-from: type=gha cache-from: type=gha
@ -176,9 +164,6 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -210,7 +195,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
file: build/package/Dockerfile file: build/package/Dockerfile
@ -246,9 +230,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -269,7 +250,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
push: true push: true
tags: user/app:latest tags: user/app:latest
cache-from: type=local,src=/tmp/.buildx-cache cache-from: type=local,src=/tmp/.buildx-cache

View File

@ -49,9 +49,6 @@ jobs:
buildx: buildx:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
@ -59,8 +56,6 @@ jobs:
- name: Build - name: Build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with:
context: .
``` ```
Logs will be available at the end of a job: Logs will be available at the end of a job:
@ -88,9 +83,6 @@ jobs:
buildx: buildx:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
@ -126,9 +118,6 @@ jobs:
buildx: buildx:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
@ -312,9 +301,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up builder1 - name: Set up builder1
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
id: builder1 id: builder1
@ -327,13 +313,11 @@ jobs:
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
builder: ${{ steps.builder1.outputs.name }} builder: ${{ steps.builder1.outputs.name }}
context: .
target: mytarget1 target: mytarget1
- name: Build against builder2 - name: Build against builder2
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
builder: ${{ steps.builder2.outputs.name }} builder: ${{ steps.builder2.outputs.name }}
context: .
target: mytarget2 target: mytarget2
``` ```

View File

@ -17,9 +17,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -42,7 +39,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: | tags: |

View File

@ -17,17 +17,12 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Build - name: Build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
load: true load: true
tags: myimage:latest tags: myimage:latest

View File

@ -22,9 +22,6 @@ jobs:
ports: ports:
- 5000:5000 - 5000:5000
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -36,7 +33,6 @@ jobs:
- name: Build and push to local registry - name: Build and push to local registry
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
push: true push: true
tags: localhost:5000/name/app:latest tags: localhost:5000/name/app:latest

View File

@ -26,9 +26,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta - name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
@ -71,7 +68,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}

View File

@ -24,9 +24,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -42,7 +39,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: user/app:latest tags: user/app:latest
@ -90,9 +86,6 @@ jobs:
platform=${{ matrix.platform }} platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta - name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
@ -115,7 +108,6 @@ jobs:
id: build id: build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: ${{ matrix.platform }} platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

View File

@ -31,16 +31,12 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Build - name: Build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
build-contexts: | build-contexts: |
alpine=docker-image://alpine:{{% param "example_alpine_version" %}} alpine=docker-image://alpine:{{% param "example_alpine_version" %}}
tags: myimage:latest tags: myimage:latest
@ -70,9 +66,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
@ -81,15 +74,13 @@ jobs:
- name: Build base image - name: Build base image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: ./base context: "{{defaultContext}}:base"
file: ./base/Dockerfile
load: true load: true
tags: my-base-image:latest tags: my-base-image:latest
- name: Build - name: Build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
build-contexts: | build-contexts: |
alpine=docker-image://my-base-image:latest alpine=docker-image://my-base-image:latest
tags: myimage:latest tags: myimage:latest
@ -124,9 +115,6 @@ jobs:
ports: ports:
- 5000:5000 - 5000:5000
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -139,15 +127,13 @@ jobs:
- name: Build base image - name: Build base image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: ./base context: "{{defaultContext}}:base"
file: ./base/Dockerfile
tags: localhost:5000/my-base-image:latest tags: localhost:5000/my-base-image:latest
push: true push: true
- name: Build - name: Build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
build-contexts: | build-contexts: |
alpine=docker-image://localhost:5000/my-base-image:latest alpine=docker-image://localhost:5000/my-base-image:latest
tags: myimage:latest tags: myimage:latest

View File

@ -17,9 +17,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -42,7 +39,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: | tags: |

View File

@ -31,16 +31,12 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Build - name: Build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
tags: user/app:latest tags: user/app:latest
env: env:
SOURCE_DATE_EPOCH: 0 SOURCE_DATE_EPOCH: 0
@ -91,9 +87,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -103,7 +96,6 @@ jobs:
- name: Build - name: Build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
tags: user/app:latest tags: user/app:latest
env: env:
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }} SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}

View File

@ -42,9 +42,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -54,7 +51,6 @@ jobs:
- name: Build - name: Build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
tags: user/app:latest tags: user/app:latest
secrets: | secrets: |
@ -174,9 +170,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up SSH - name: Set up SSH
uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a # v3.1.0 uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a # v3.1.0
with: with:
@ -187,7 +180,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
ssh: default ssh: default
push: true push: true
tags: user/app:latest tags: user/app:latest
@ -207,7 +199,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set up SSH - name: Set up SSH
uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a # v3.1.0 uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a # v3.1.0

View File

@ -21,16 +21,12 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Build and export - name: Build and export
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
tags: myimage:latest tags: myimage:latest
outputs: type=docker,dest=/tmp/myimage.tar outputs: type=docker,dest=/tmp/myimage.tar

View File

@ -26,9 +26,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -44,7 +41,6 @@ jobs:
- name: Build and export to Docker - name: Build and export to Docker
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
load: true load: true
tags: ${{ env.TEST_TAG }} tags: ${{ env.TEST_TAG }}
@ -55,7 +51,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ env.LATEST_TAG }} tags: ${{ env.LATEST_TAG }}

View File

@ -18,9 +18,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -36,7 +33,6 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
push: true push: true
tags: user/app:latest tags: user/app:latest

View File

@ -63,8 +63,6 @@ jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Docker Hub - name: Log in to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
@ -80,11 +78,10 @@ jobs:
- name: Build and push - name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
tags: "<IMAGE>" tags: "<IMAGE>"
# For pull requests, export results to the build cache. # For pull requests, export results to the build cache.
# Otherwise, push to a registry. # Otherwise, push to a registry.
outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry,push=true' }} outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }}
``` ```
{{< /tab >}} {{< /tab >}}

View File

@ -77,9 +77,6 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -93,8 +90,6 @@ jobs:
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
file: ./Dockerfile
push: true push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/clockbox:latest tags: ${{ secrets.DOCKERHUB_USERNAME }}/clockbox:latest
``` ```
@ -102,18 +97,15 @@ jobs:
The previous YAML snippet contains a sequence of steps that: The previous YAML snippet contains a sequence of steps that:
1. Checks out the repository on the build machine. 1. Signs in to Docker Hub, using the
2. Signs in to Docker Hub, using the
[Docker Login](https://github.com/marketplace/actions/docker-login) action and your Docker Hub credentials. [Docker Login](https://github.com/marketplace/actions/docker-login) action and your Docker Hub credentials.
3. Creates a BuildKit builder instance using the 2. Creates a BuildKit builder instance using the
[Docker Setup Buildx](https://github.com/marketplace/actions/docker-setup-buildx) action. [Docker Setup Buildx](https://github.com/marketplace/actions/docker-setup-buildx) action.
4. Builds the container image and pushes it to the Docker Hub repository, using 3. Builds the container image and pushes it to the Docker Hub repository, using
[Build and push Docker images](https://github.com/marketplace/actions/build-and-push-docker-images). [Build and push Docker images](https://github.com/marketplace/actions/build-and-push-docker-images).
The `with` key lists a number of input parameters that configures the step: The `with` key lists a number of input parameters that configures the step:
- `context`: the [build context](/build/building/context/).
- `file`: filepath to the Dockerfile.
- `push`: tells the action to upload the image to a registry after building - `push`: tells the action to upload the image to a registry after building
it. it.
- `tags`: tags that specify where to push the image. - `tags`: tags that specify where to push the image.
@ -134,9 +126,6 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -150,8 +139,6 @@ jobs:
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
file: ./Dockerfile
push: true push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/clockbox:latest tags: ${{ secrets.DOCKERHUB_USERNAME }}/clockbox:latest
``` ```
@ -173,4 +160,4 @@ Save the workflow file and run the job.
[repositories on Docker Hub](https://hub.docker.com/repositories). [repositories on Docker Hub](https://hub.docker.com/repositories).
If you see the new repository in that list, it means the GitHub Actions If you see the new repository in that list, it means the GitHub Actions
successfully pushed the image to Docker Hub! successfully pushed the image to Docker Hub!

View File

@ -75,9 +75,6 @@ to Docker Hub.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -91,15 +88,13 @@ to Docker Hub.
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
``` ```
If your Dockerfile is in a different directory, update the `context` with the path to the directory containing the Dockerfile. For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).
For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions).
## Step three: Run the workflow ## Step three: Run the workflow

View File

@ -83,9 +83,6 @@ to Docker Hub.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -99,23 +96,20 @@ to Docker Hub.
name: Build and test name: Build and test
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
target: build target: build
load: true load: true
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
target: final target: final
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
``` ```
If your Dockerfile is in a different directory, update the `context` with the path to the directory containing the Dockerfile. For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).
For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions).
## Step three: Run the workflow ## Step three: Run the workflow
@ -147,4 +141,4 @@ Related information:
Next, learn how you can locally test and debug your workloads on Kubernetes before deploying. Next, learn how you can locally test and debug your workloads on Kubernetes before deploying.
{{< button text="Test your deployment" url="./deploy.md" >}} {{< button text="Test your deployment" url="./deploy.md" >}}

View File

@ -75,9 +75,6 @@ to Docker Hub.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -91,15 +88,13 @@ to Docker Hub.
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
``` ```
If your Dockerfile is in a different directory, update the `context` with the path to the directory containing the Dockerfile. For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).
For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions).
## Step three: Run the workflow ## Step three: Run the workflow

View File

@ -78,9 +78,6 @@ to Docker Hub.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -94,23 +91,20 @@ to Docker Hub.
name: Build and test name: Build and test
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
target: test target: test
load: true load: true
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
target: final target: final
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
``` ```
If your Dockerfile is in a different directory, update the `context` with the path to the directory containing the Dockerfile.
For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions). For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).
## Step three: Run the workflow ## Step three: Run the workflow
@ -142,4 +136,4 @@ Related information:
Next, learn how you can locally test and debug your workloads on Kubernetes before deploying. Next, learn how you can locally test and debug your workloads on Kubernetes before deploying.
{{< button text="Test your deployment" url="./deploy.md" >}} {{< button text="Test your deployment" url="./deploy.md" >}}

View File

@ -77,9 +77,6 @@ to Docker Hub.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -93,23 +90,20 @@ to Docker Hub.
name: Build and test name: Build and test
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
target: test target: test
load: true load: true
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64/v8 platforms: linux/amd64,linux/arm64/v8
push: true push: true
target: prod target: prod
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
``` ```
If your Dockerfile is in a different directory, update the `context` with the path to the directory containing the Dockerfile. For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).
For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions).
## Step three: Run the workflow ## Step three: Run the workflow
@ -141,4 +135,4 @@ Related information:
Next, learn how you can locally test and debug your workloads on Kubernetes before deploying. Next, learn how you can locally test and debug your workloads on Kubernetes before deploying.
{{< button text="Test your deployment" url="./deploy.md" >}} {{< button text="Test your deployment" url="./deploy.md" >}}

View File

@ -83,9 +83,6 @@ to Docker Hub.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -99,23 +96,20 @@ to Docker Hub.
name: Build and test name: Build and test
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
target: test target: test
load: true load: true
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
target: final target: final
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
``` ```
If your Dockerfile is in a different directory, update the `context` with the path to the directory containing the Dockerfile.
For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions). For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).
## Step three: Run the workflow ## Step three: Run the workflow
@ -147,4 +141,4 @@ Related information:
Next, learn how you can locally test and debug your workloads on Kubernetes before deploying. Next, learn how you can locally test and debug your workloads on Kubernetes before deploying.
{{< button text="Test your deployment" url="./deploy.md" >}} {{< button text="Test your deployment" url="./deploy.md" >}}

View File

@ -75,9 +75,6 @@ to Docker Hub.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -91,15 +88,13 @@ to Docker Hub.
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
``` ```
If your Dockerfile is in a different directory, update the `context` with the path to the directory containing the Dockerfile. For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).
For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions).
## Step three: Run the workflow ## Step three: Run the workflow
@ -131,4 +126,4 @@ Related information:
Next, learn how you can locally test and debug your workloads on Kubernetes before deploying. Next, learn how you can locally test and debug your workloads on Kubernetes before deploying.
{{< button text="Test your deployment" url="./deploy.md" >}} {{< button text="Test your deployment" url="./deploy.md" >}}

View File

@ -75,9 +75,6 @@ to Docker Hub.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -91,13 +88,13 @@ to Docker Hub.
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
``` ```
For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions). For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).
## Step three: Run the workflow ## Step three: Run the workflow
@ -129,4 +126,4 @@ Related information:
Next, learn how you can locally test and debug your workloads on Kubernetes before deploying. Next, learn how you can locally test and debug your workloads on Kubernetes before deploying.
{{< button text="Test your deployment" url="./deploy.md" >}} {{< button text="Test your deployment" url="./deploy.md" >}}

View File

@ -75,9 +75,6 @@ to Docker Hub.
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Login to Docker Hub name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -91,14 +88,12 @@ to Docker Hub.
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
push: true push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
``` ```
If your Dockerfile is in a different directory, update the `context` with the path to the directory containing the Dockerfile. For more information about the YAML syntax for `docker/build-push-action`,
refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md).
For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions).
## Step three: Run the workflow ## Step three: Run the workflow

View File

@ -55,11 +55,6 @@ jobs:
pull-requests: write pull-requests: write
steps: steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.SHA }}
- name: Setup Docker buildx - name: Setup Docker buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -90,7 +85,6 @@ jobs:
id: build-and-push id: build-and-push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: .
sbom: ${{ github.event_name != 'pull_request' }} sbom: ${{ github.event_name != 'pull_request' }}
provenance: ${{ github.event_name != 'pull_request' }} provenance: ${{ github.event_name != 'pull_request' }}
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
@ -103,11 +97,10 @@ jobs:
This creates workflow steps to: This creates workflow steps to:
1. Check out the repository. 1. Set up Docker buildx.
2. Set up Docker buildx. 2. Authenticate to the registry.
3. Authenticate to the registry. 3. Extract metadata from Git reference and GitHub events.
4. Extract metadata from Git reference and GitHub events. 4. Build and push the Docker image to the registry.
5. Build and push the Docker image to the registry.
> **Note** > **Note**
> >

View File

@ -94,9 +94,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker buildx - name: Setup Docker buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -117,7 +114,6 @@ jobs:
id: build-and-push id: build-and-push
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
context: .
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
sbom: ${{ github.event_name != 'pull_request' }} sbom: ${{ github.event_name != 'pull_request' }}