-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (75 loc) · 2.73 KB
/
build-containers.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 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 }}