Skip to content

Commit

Permalink
Merge pull request #78 from joel-ling/main
Browse files Browse the repository at this point in the history
build, push multi-arch images to Docker Hub
  • Loading branch information
joel-ling authored Jul 9, 2024
2 parents d1fec5a + 7f98a4d commit 103892a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build-image-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Build and push Docker image tagged main

on:
push:
branches:
- main

permissions:
contents: read # principle of least privilege

jobs:
build:
name: Build and push Docker image tagged main
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx for multi-platform builds
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ vars.PLATFORMS }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
platforms: ${{ vars.PLATFORMS }}
push: true
sbom: true
tags: >-
${{ secrets.DOCKERHUB_ORGANIZATION_NAME }}/${{ vars.IMAGE_NAME }}:main
40 changes: 40 additions & 0 deletions .github/workflows/build-image-semver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Build and push semver-tagged Docker image

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+

permissions:
contents: read # principle of least privilege

jobs:
build:
name: Build and push semver-tagged Docker image
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx for multi-platform builds
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ vars.PLATFORMS }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Derive image tag(s)
uses: docker/metadata-action@v5
with:
images: >-
${{ secrets.DOCKERHUB_ORGANIZATION_NAME }}/${{ vars.IMAGE_NAME }}
tags: type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
platforms: ${{ vars.PLATFORMS }}
push: true
sbom: true
tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }}

0 comments on commit 103892a

Please sign in to comment.