Skip to content

2023-09-28

2023-09-28 #10

Workflow file for this run

name: Container build
"on":
release:
types:
- published
pull_request:
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/matrix.yml"
from: "yaml"
to: "json"
build:
name: Build container
needs: prepare-matrix
runs-on: ${{ matrix.runs-on }}
strategy:
# fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
if: ${{ !github.event.act }}
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Process base image
id: base-image
run: |
PY_VERSION=$(./run.sh extract-version "${{ matrix.base-image }}")
echo "::set-output name=py-version::$PY_VERSION"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ steps.base-image.outputs.py-version }}
tags: |
type=schedule
type=raw,value=${{ matrix.ansible-core-version }}
# git short commit
type=sha
- name: Build
uses: docker/build-push-action@v4
with:
context: .
load: true
build-args: |
BASE_IMAGE=${{ matrix.base-image }}
ANSIBLE_CORE_VERSION=${{ matrix.ansible-core-version }}
tags: app:latest
- name: Test
run: |
docker run --rm app:latest ansible --version
- name: Login to GitHub Container Registry
if: github.event_name == 'release' && !github.event.act
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
if: github.event_name == 'release' && !github.event.act
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
BASE_IMAGE=${{ matrix.base-image }}
ANSIBLE_CORE_VERSION=${{ matrix.ansible-core-version }}
tags: ${{ steps.meta.outputs.tags }}