Skip to content

Commit

Permalink
use docker/metadata-action in build workflow (#34)
Browse files Browse the repository at this point in the history
Signed-off-by: svrnm <[email protected]>
  • Loading branch information
svrnm authored Dec 17, 2024
1 parent 4c4b0a2 commit 77fc6b3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-images-on-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ jobs:
uses: ./.github/workflows/reusable-build-container-images.yml
with:
push: true
release_stream: dev
secrets: inherit
File renamed without changes.
11 changes: 11 additions & 0 deletions .github/workflows/build-images-on-schedule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Build and publish nightly container images
on:
schedule:
- cron: '0 0 * * *'
jobs:
build:
uses: ./.github/workflows/reusable-build-container-images.yml
with:
push: true
secrets: inherit
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
name: Build and publish release container images
on:
release:
types: [published]
push:
tags:
- 'v*.*.*'
jobs:
build:
uses: ./.github/workflows/reusable-build-container-images.yml
with:
push: true
release_stream: latest
secrets: inherit
31 changes: 17 additions & 14 deletions .github/workflows/reusable-build-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ on:
default: false
required: false
type: boolean
release_stream:
type: string
description: Set the release stream (latest, dev, ...)
required: false
default: dev
registry_ghcr:
description: github container registry
default: "ghcr.io/cisco-open/app-simulator"
Expand All @@ -30,16 +25,24 @@ jobs:
steps:
- name: Checkout
uses: actions/[email protected]
- name: Bump version
# Only bump the version if the release stream is not 'latest'
# This way we make sure that released versions are fixed to their version
# and that 'dev' or other non stable releases do not overwrite.
if: ${{ inputs.release_stream != 'latest' }}
run: ./scripts/bumpversion.sh --patch
- name: Read version from .version file
id: version
run: |
echo "version=$(cat .version)" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.registry_ghcr }}-${{ matrix.image.name }} # e.g. ghcr.io/cisco-open/app-simulator-loaders-curl
# build nightly releases on schedule
# build semver releases on tag
# build edge releases on main branch
tags: |
type=schedule,pattern={{date 'YYYYMMDD'}}
type=semver,pattern={{ version }}
type=edge,branch=main
labels: |
- name: Log into GitHub Container Registry
if: ${{ inputs.push }}
uses: docker/login-action@v3
Expand All @@ -59,8 +62,8 @@ jobs:
context: ${{ matrix.image.context }}
platforms: linux/amd64,linux/arm64
push: ${{ inputs.push }}
tags: |
${{ inputs.registry_ghcr }}-${{ matrix.image.name }}:${{ steps.version.outputs.version }}
${{ inputs.registry_ghcr }}-${{ matrix.image.name }}:${{ inputs.release_stream }}
cache-from: type=gha
cache-to: type=gha
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}

0 comments on commit 77fc6b3

Please sign in to comment.