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 >}}
{{< tab name="build-push-action" >}}
```yaml {hl_lines=35}
```yaml {hl_lines=32}
name: ci
on:
@ -32,9 +32,6 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
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
manifests.
```yaml {hl_lines=31}
```yaml {hl_lines=28}
name: ci
on:
@ -130,9 +127,6 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -63,8 +63,6 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
@ -80,11 +78,10 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
tags: "<IMAGE>"
# For pull requests, export results to the build cache.
# 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 >}}

View File

@ -77,9 +77,6 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -93,8 +90,6 @@ jobs:
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/clockbox:latest
```
@ -102,18 +97,15 @@ jobs:
The previous YAML snippet contains a sequence of steps that:
1. Checks out the repository on the build machine.
2. Signs in to Docker Hub, using the
1. Signs in to Docker Hub, using the
[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.
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).
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
it.
- `tags`: tags that specify where to push the image.
@ -134,9 +126,6 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -150,8 +139,6 @@ jobs:
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
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).
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:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -91,15 +88,13 @@ to Docker Hub.
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
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

View File

@ -83,9 +83,6 @@ to Docker Hub.
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -99,23 +96,20 @@ to Docker Hub.
name: Build and test
uses: docker/build-push-action@v6
with:
context: .
target: build
load: true
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
target: final
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
@ -147,4 +141,4 @@ Related information:
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:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -91,15 +88,13 @@ to Docker Hub.
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
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

View File

@ -78,9 +78,6 @@ to Docker Hub.
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -94,23 +91,20 @@ to Docker Hub.
name: Build and test
uses: docker/build-push-action@v6
with:
context: .
target: test
load: true
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
target: final
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
@ -142,4 +136,4 @@ Related information:
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:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -93,23 +90,20 @@ to Docker Hub.
name: Build and test
uses: docker/build-push-action@v6
with:
context: .
target: test
load: true
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64/v8
push: true
target: prod
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
@ -141,4 +135,4 @@ Related information:
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:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -99,23 +96,20 @@ to Docker Hub.
name: Build and test
uses: docker/build-push-action@v6
with:
context: .
target: test
load: true
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
target: final
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
@ -147,4 +141,4 @@ Related information:
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:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -91,15 +88,13 @@ to Docker Hub.
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
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
@ -131,4 +126,4 @@ Related information:
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:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -91,13 +88,13 @@ to Docker Hub.
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
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
@ -129,4 +126,4 @@ Related information:
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:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
@ -91,14 +88,12 @@ to Docker Hub.
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
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

View File

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

View File

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