Skip to content

Commit

Permalink
add container build workflow (#9)
Browse files Browse the repository at this point in the history
* add container build workflow

Signed-off-by: svrnm <[email protected]>

* remove nightly

Signed-off-by: svrnm <[email protected]>

* add dev workflow

Signed-off-by: svrnm <[email protected]>

* update check to run on pull request target

Signed-off-by: svrnm <[email protected]>

* use ubuntu 24.04

Signed-off-by: svrnm <[email protected]>

* manage versions better

Signed-off-by: svrnm <[email protected]>

* adjusted directory structure & scripts fo a more clean repo (#10)

* move to src

Signed-off-by: svrnm <[email protected]>

* Update .github/workflows/reusable-build-container-images.yml

* Update .github/workflows/reusable-build-container-images.yml

---------

Signed-off-by: svrnm <[email protected]>
Co-authored-by: Alexander Stoklasa <[email protected]>
  • Loading branch information
svrnm and noMoreCLI authored Dec 10, 2024
1 parent 21baa05 commit 33ac5ac
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
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 }}

0 comments on commit 33ac5ac

Please sign in to comment.