Skip to content

Build Containers

Build Containers #16

# build all container files in this repository & push it to GHCR
name: Build Containers
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
container:
- ./ansible|./ansible/Dockerfile|ansible:latest
- ./ansible-playbook|./ansible-playbook/Dockerfile|ansible-playbook:latest
- ./packer-vmware|./packer-vmware/Dockerfile|packer-vmware:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prep variables for build and push
shell: bash
run: |
set -exuo pipefail
(
echo CONTEXT="$(cut -d '|' -f 1 <<< "${{ matrix.container }}")"
echo DOCKERFILE="$(cut -d '|' -f 2 <<< "${{ matrix.container }}")"
echo DOCKER_TAG="$(cut -d '|' -f 3 <<< "${{ matrix.container }}")"
) >> $GITHUB_ENV
- name: Build and push ${{ matrix.container }}
uses: docker/build-push-action@v6
with:
context: ${{ env.CONTEXT }}
file: ${{ env.DOCKERFILE }}
push: true
tags: ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_TAG }}
build-packer-vmware:
runs-on: ubuntu-latest
strategy:
matrix:
ubuntu_version: [20.04, 22.04, 24.04]
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push packer-vmware with UBUNTU_VERSION=${{ matrix.ubuntu_version }}
uses: docker/build-push-action@v6
with:
context: ./packer-vmware
file: ./packer-vmware/Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/packer-vmware:${{ matrix.ubuntu_version }}
build-args: UBUNTU_VERSION=${{ matrix.ubuntu_version }}