Skip to content

Commit

Permalink
Add multi-image support (#152)
Browse files Browse the repository at this point in the history
Signed-off-by: cyclinder <[email protected]>
  • Loading branch information
cyclinder authored Jun 13, 2024
1 parent 0e7adea commit dfda185
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/image-push-master.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
name: "Push images on merge to master"

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le

on:
push:
branches:
- master
jobs:
build-and-push-image-nri:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}

- name: Build and push network-resources-injector
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.BUILD_PLATFORMS }}
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile
28 changes: 21 additions & 7 deletions .github/workflows/image-push-release.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
name: "Push images on release"

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le

on:
push:
tags:
- v*
jobs:
build-and-push-image-nri:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false
flavor: |
latest=false
- name: Build and push network-resources-injector
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ env.BUILD_PLATFORMS }}
tags: |
${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile

0 comments on commit dfda185

Please sign in to comment.