Skip to content

Commit

Permalink
Merge branch 'main' into java-service
Browse files Browse the repository at this point in the history
  • Loading branch information
noMoreCLI authored Dec 10, 2024
2 parents 58b4336 + ca7f9e1 commit 748a2af
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 4 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build-images-on-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build and publish dev container images

on:
push:
branches: [ main ]
paths:
- 'src/loaders/**'
- 'src/services/**'
- '.version'
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/reusable-build-container-images.yml
with:
push: true
release_stream: dev
secrets: inherit
16 changes: 16 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check container builds

on:
pull_request_target:
branches: [ main ]
paths:
- 'src/loaders/**'
- 'src/services/**'
- '.version'

jobs:
build:
uses: ./.github/workflows/reusable-build-container-images.yml
with:
push: false
release_stream: dev
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Build and publish release container images

on:
release:
types: [published]

jobs:
build:
uses: ./.github/workflows/reusable-build-container-images.yml
with:
push: true
release_stream: latest
secrets: inherit
63 changes: 63 additions & 0 deletions .github/workflows/reusable-build-container-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
on:
workflow_call:
inputs:
push:
description: Set to true to push images to registries
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'
required: false
type: string
jobs:
build:
runs-on: ubuntu-24.04
strategy:
matrix:
image:
- context: ./src/loaders/curl
name: loaders-curl

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 "::set-output name=version::$(cat .version)"
- name: Log into GitHub Container Registry
if: ${{ inputs.push }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: cisco-service
password: ${{ secrets.PACKAGE_PUBLICATION_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64, amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push images
uses: docker/build-push-action@v6
with:
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
8 changes: 4 additions & 4 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ REPO_DIR=$(dirname $0)/..
#MacOSX M architecture: linux/arm64/v8
PLATFORM="linux/amd64"
IMAGE_PREFIX="app-simulator"
REPO_PREFIX="cisco-open"
VERSION=$($REPO_DIR/scripts/bumpversion.sh)

# Function to display help
Expand All @@ -31,7 +32,7 @@ for ARG in "$@"; do
shift
;;
--repoprefix=*)
IMAGE_PREFIX="${ARG#*=}"
REPO_PREFIX="${ARG#*=}"
shift
;;
--help)
Expand All @@ -49,7 +50,7 @@ done
for DIR in $REPO_DIR/src/services/*;
do
if [ -d $DIR ] ; then
IMAGE_TAG="${IMAGE_PREFIX}/services-$(basename "$DIR"):$VERSION"
IMAGE_TAG="${REPO_PREFIX}/${IMAGE_PREFIX}-services-$(basename "$DIR"):$VERSION"
echo "Building $IMAGE_TAG..."
echo "Running 'docker buildx build --platform $PLATFORM -t $IMAGE_TAG $DIR $PUSH'"
docker buildx build --platform $PLATFORM -t $IMAGE_TAG $PUSH $DIR
Expand All @@ -59,8 +60,7 @@ done;
for DIR in $REPO_DIR/src/loaders/*;
do
if [ -d $DIR ] ; then
IMAGE_TAG="${IMAGE_PREFIX}/loaders-$(basename "$DIR"):$VERSION"
echo "Building $IMAGE_TAG..."
IMAGE_TAG="${REPO_PREFIX}/${IMAGE_PREFIX}-loaders-$(basename "$DIR"):$VERSION"
echo "Building $IMAGE_TAG..."
echo "Running 'docker buildx build --platform $PLATFORM -t $IMAGE_TAG $DIR $PUSH'"
docker buildx build --platform $PLATFORM -t $IMAGE_TAG $PUSH $DIR $PUSH
Expand Down

0 comments on commit 748a2af

Please sign in to comment.