Skip to content

Container build

Container build #1

name: Container build
"on":
release:
types:
- released
workflow_dispatch:
jobs:
prepare-matrix:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.matrix.outputs.output }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: fabasoad/data-format-converter-action@main
id: matrix
with:
input: ".github/container-matrix.yml"
from: "yaml"
to: "json"
build:
name: Build container
runs-on: ubuntu-22.04
needs: prepare-matrix
strategy:
# fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Process ansible core image version
id: core-image
run: |
CORE_VERSION=$(./run.sh _transformAnsibleCoreVersion "${{ matrix.ansible-core-image }}")
echo "::set-output name=core-version::$CORE_VERSION"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ steps.core-image.outputs.core-version }}
tags: |
type=ref,event=tag
type=ref,event=branch
# git short commit
type=sha
- name: Build
uses: docker/build-push-action@v4
with:
context: .
load: true
build-args: |
BASE_IMAGE=ghcr.io/srl-labs/ansible-core/${{ matrix.ansible-core-image }}
tags: app:latest
- name: Test
run: |
sudo docker run --rm app:latest ansible-galaxy collection list | grep -q 'nokia.srlinux' || exit 1
- name: Login to GitHub Container Registry
if: "!github.event.act"
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
if: "!github.event.act"
uses: docker/setup-qemu-action@v3
- name: Build and Push
if: "!github.event.act"
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
BASE_IMAGE=ghcr.io/srl-labs/ansible-core/${{ matrix.ansible-core-image }}
tags: ${{ steps.meta.outputs.tags }}