Skip to content

trying to build multiple docker images #12

trying to build multiple docker images

trying to build multiple docker images #12

# 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:
- name: ansible
context: ./ansible
dockerfile: ./ansible/Dockerfile
tag: ansible:latest
- name: ansible-playbook
context: ./ansible-playbook
dockerfile: ./ansible-playbook/Dockerfile
tag: ansible-playbook:latest
- name: packer-vmware
context: ./packer-vmware
dockerfile: ./packer-vmware/Dockerfile
tag: packer-vmware:latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ${{ matrix.container.name }}
uses: docker/build-push-action@v2
with:
context: ${{ matrix.container.context }}
file: ${{ matrix.container.dockerfile }}
push: true
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.container.tag }}
build-packer-vmware:
runs-on: ubuntu-latest
strategy:

Check failure on line 54 in .github/workflows/build-containers.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-containers.yml

Invalid workflow file

You have an error in your yaml syntax on line 54
matrix:
container:
- name: packer-vmware
context: ./packer-vmware
dockerfile: ./packer-vmware/Dockerfile
image_name: packer-vmware
build_args:
- name: UBUNTU_VERSION
version: 20.04
- name: UBUNTU_VERSION
version: 22.04
- name: UBUNTU_VERSION
version: 24.04
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ${{ matrix.container.name }}
uses: docker/build-push-action@v2
with:
context: ${{ matrix.container.context }}
file: ${{ matrix.container.dockerfile }}
push: true
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.container.image_name }}:${{ matrix.build_args.version }}
build-args:
- ${{ matrix.build_args.name }}=${{ matrix.build_args.version }}