trying to build multiple docker images #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: | ||
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 }} |