Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add container build workflow #9

Merged
merged 11 commits into from
Dec 10, 2024
17 changes: 17 additions & 0 deletions .github/workflows/build-images-on-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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
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
60 changes: 60 additions & 0 deletions .github/workflows/reusable-build-container-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_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 }}
Loading