Skip to content

Commit

Permalink
add GitHub w/flow for building master image
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-ling committed Jul 8, 2024
1 parent d30b7ff commit d49ee3e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build-image-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Build and push Docker image tagged master

on:
push:
branches:
- main

permissions:
contents: read # principle of least privilege

jobs:
build:
name: Build and push Docker image tagged master
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 }}:master
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Build and push Docker image
name: Build and push semver-tagged Docker image

on:
push:
Expand All @@ -11,19 +11,15 @@ permissions:

jobs:
build:
name: Build and push Docker image
name: Build and push semver-tagged Docker image
runs-on: ubuntu-22.04
env:
PLATFORMS: linux/amd64,linux/arm64/v8
IMAGE_NAME: lightningstream
IMAGE_TAGS: type=semver,pattern={{version}}
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: ${{ env.PLATFORMS }}
platforms: ${{ vars.PLATFORMS }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -33,12 +29,12 @@ jobs:
uses: docker/metadata-action@v5
with:
images: >-
${{ secrets.DOCKERHUB_ORGANIZATION_NAME }}/${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}
${{ 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: ${{ env.PLATFORMS }}
platforms: ${{ vars.PLATFORMS }}
push: true
sbom: true
tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }}

0 comments on commit d49ee3e

Please sign in to comment.