Skip to content

Commit

Permalink
chore(ci,ansible,images): properly use image tag.
Browse files Browse the repository at this point in the history
Moreover, added a reusable workflow to build and eventually push images.
Images makefile does now support pushing tagged and latest images too now.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Jan 30, 2024
1 parent 882791d commit edb1f03
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 108 deletions.
26 changes: 12 additions & 14 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
name: ansible-lint
on:
pull_request:
pull_request:


jobs:
build:
name: Ansible Lint
runs-on: ubuntu-latest
build:
name: Ansible Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Run ansible-lint
# replace `main` with any valid ref, or tags like `v6`
uses: ansible/[email protected] # the latest version has a bug that does not run in online mode
with:
path: "ansible-playbooks/"
- name: Run ansible-lint
uses: ansible/[email protected] # the latest version has a bug that does not run in online mode
with:
path: "ansible-playbooks/"
53 changes: 8 additions & 45 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,20 @@
name: Build and Push docker images
name: Main CI
on:
pull_request:
branches:
- main
paths:
- 'images/**'
push:
branches:
- main
paths:
- 'images/**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
group: main_push_images
cancel-in-progress: true

jobs:
# Job responsible to test the build of the images and, only on main CI, to push them too.
push-images:
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
runs-on: ${{ (matrix.arch == 'arm64' && 'actuated-arm64-8cpu-16gb') || 'ubuntu-22.04' }}
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Login to Github Packages
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Sets PUSH env var for main push
if: ${{ github.event_name == 'push' }}
run: |
echo "PUSH=true" >> $GITHUB_ENV
- name: Build images
working-directory: ./images
run: |
touch failed.txt
make build-all
- name: Check failures
working-directory: ./images
run: |
if [ -s failed.txt ]; then
cat failed.txt
exit 1;
fi
uses: ./.github/workflows/reusable_build_images.yml
with:
push: true
is_latest: false
version: 'main'
secrets: inherit
20 changes: 20 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR CI
on:
pull_request:
branches:
- main
paths:
- 'images/**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build-images:
uses: ./.github/workflows/reusable_build_images.yml
with:
push: false
is_latest: false
version: '${{ github.run_id }}'
secrets: inherit
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Release CI
on:
release:
types: [published]

concurrency:
group: release_push_images
cancel-in-progress: true

jobs:
release-images:
uses: ./.github/workflows/reusable_build_images.yml
with:
push: true
is_latest: true
version: ${{ github.event.release.tag_name }}
secrets: inherit
69 changes: 69 additions & 0 deletions .github/workflows/reusable_build_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build and Push docker images
on:
workflow_call:
inputs:
version:
description: 'docker images version to be built/tagged'
type: string
required: false
default: 'main'
push:
description: 'whether to push images or build only'
type: boolean
required: false
default: false
is_latest:
description: 'whether we need to also push latest images'
type: boolean
required: false
default: false

jobs:
# Job responsible to test the build of the images and, only on main CI, to push them too.
build-images:
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
runs-on: ${{ (matrix.arch == 'arm64' && 'actuated-arm64-8cpu-16gb') || 'ubuntu-22.04' }}
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Login to Github Packages
if: inputs.push
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set PUSH env var
if: inputs.push
run: |
echo "PUSH=true" >> $GITHUB_ENV
- name: Set LATEST env var
if: inputs.is_latest
run: |
echo "LATEST=true" >> $GITHUB_ENV
- name: Set TAG env var
run: |
echo "TAG=${{ inputs.version }}" >> $GITHUB_ENV
- name: Build images
working-directory: ./images
run: |
touch failed.txt
make build-all
- name: Check failures
working-directory: ./images
run: |
if [ -s failed.txt ]; then
cat failed.txt
exit 1;
fi
61 changes: 32 additions & 29 deletions ansible-playbooks/group_vars/all/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,46 @@ user: root
# Machine Configuration #
#########################

# Images version to be used.
version: main

# Each machine entry requires the following fields
# name: the name given to the vm;
# kernel: reference to an OCI image containing a kernel;
# rootfs: reference to an OCI image used as base rootfs for the vm.
# arch: architecture of the kernel and base images. (x86_64/aarch64).
machines:
- {name: "amazonlinux2022-5.15", kernel: "therealbobo/amazonlinux2022-kernel:5.15-x86_64", rootfs: "therealbobo/amazonlinux2022-image:5.15-x86_64", arch: "x86_64"} # noqa: yaml[line-length]
- {name: "amazonlinux2023-6.1", kernel: "therealbobo/amazonlinux2023-kernel:6.1-x86_64", rootfs: "therealbobo/amazonlinux2023-image:6.1-x86_64", arch: "x86_64"} # noqa: yaml[line-length]
- {name: "amazonlinux2-4.19", kernel: "therealbobo/amazonlinux2-kernel:4.19-x86_64", rootfs: "therealbobo/amazonlinux2-image:4.19-x86_64", arch: "x86_64"}
- {name: "amazonlinux2-5.10", kernel: "therealbobo/amazonlinux2-kernel:5.10-x86_64", rootfs: "therealbobo/amazonlinux2-image:5.10-x86_64", arch: "x86_64"}
- {name: "amazonlinux2-5.15", kernel: "therealbobo/amazonlinux2-kernel:5.15-x86_64", rootfs: "therealbobo/amazonlinux2-image:5.15-x86_64", arch: "x86_64"}
- {name: "amazonlinux2-5.4", kernel: "therealbobo/amazonlinux2-kernel:5.4-x86_64", rootfs: "therealbobo/amazonlinux2-image:5.4-x86_64", arch: "x86_64"}
- {name: "archlinux-6.0", kernel: "therealbobo/archlinux-kernel:6.0-x86_64", rootfs: "therealbobo/archlinux-image:6.0-x86_64", arch: "x86_64"}
- {name: "centos-3.10", kernel: "therealbobo/centos-kernel:3.10-x86_64", rootfs: "therealbobo/centos-image:3.10-x86_64", arch: "x86_64"}
- {name: "centos-4.18", kernel: "therealbobo/centos-kernel:4.18-x86_64", rootfs: "therealbobo/centos-image:4.18-x86_64", arch: "x86_64"}
- {name: "centos-5.14", kernel: "therealbobo/centos-kernel:5.14-x86_64", rootfs: "therealbobo/centos-image:5.14-x86_64", arch: "x86_64"}
- {name: "fedora-5.17", kernel: "therealbobo/fedora-kernel:5.17-x86_64", rootfs: "therealbobo/fedora-image:5.17-x86_64", arch: "x86_64"}
- {name: "fedora-5.8", kernel: "therealbobo/fedora-kernel:5.8-x86_64", rootfs: "therealbobo/fedora-image:5.8-x86_64", arch: "x86_64"}
- {name: "fedora-6.2", kernel: "therealbobo/fedora-kernel:6.2-x86_64", rootfs: "therealbobo/fedora-image:6.2-x86_64", arch: "x86_64"}
- {name: "oraclelinux-3.10", kernel: "therealbobo/oraclelinux-kernel:3.10-x86_64", rootfs: "therealbobo/oraclelinux-image:3.10-x86_64", arch: "x86_64"}
- {name: "oraclelinux-4.14", kernel: "therealbobo/oraclelinux-kernel:4.14-x86_64", rootfs: "therealbobo/oraclelinux-image:4.14-x86_64", arch: "x86_64"}
- {name: "oraclelinux-5.15", kernel: "therealbobo/oraclelinux-kernel:5.15-x86_64", rootfs: "therealbobo/oraclelinux-image:5.15-x86_64", arch: "x86_64"}
- {name: "oraclelinux-5.4", kernel: "therealbobo/oraclelinux-kernel:5.4-x86_64", rootfs: "therealbobo/oraclelinux-image:5.4-x86_64", arch: "x86_64"}
- {name: "ubuntu-4.15", kernel: "therealbobo/ubuntu-kernel:4.15-x86_64", rootfs: "therealbobo/ubuntu-image:4.15-x86_64", arch: "x86_64"}
- {name: "ubuntu-6.3", kernel: "therealbobo/ubuntu-kernel:6.3-x86_64", rootfs: "therealbobo/ubuntu-image:6.3-x86_64", arch: "x86_64"}
- {name: "amazonlinux2022-5.15", kernel: "therealbobo/amazonlinux2022-kernel:5.15-aarch64", rootfs: "therealbobo/amazonlinux2022-image:5.15-aarch64", arch: "aarch64"} # noqa: yaml[line-length]
- {name: "amazonlinux2-5.4", kernel: "therealbobo/amazonlinux2-kernel:5.4-aarch64", rootfs: "therealbobo/amazonlinux2-image:5.4-aarch64", arch: "aarch64"}
- {name: "fedora-6.2", kernel: "therealbobo/fedora-kernel:6.2-aarch64", rootfs: "therealbobo/fedora-image:6.2-aarch64", arch: "aarch64"}
- {name: "oraclelinux-4.14", kernel: "therealbobo/oraclelinux-kernel:4.14-aarch64", rootfs: "therealbobo/oraclelinux-image:4.14-aarch64", arch: "aarch64"}
- {name: "oraclelinux-5.15", kernel: "therealbobo/oraclelinux-kernel:5.15-aarch64", rootfs: "therealbobo/oraclelinux-image:5.15-aarch64", arch: "aarch64"}
- {name: "ubuntu-6.3", kernel: "therealbobo/ubuntu-kernel:6.3-aarch64", rootfs: "therealbobo/ubuntu-image:6.3-aarch64", arch: "aarch64"}
- {name: "amazonlinux2022-5.15", kernel: "therealbobo/amazonlinux2022-kernel:5.15-x86_64-{{ version }}", rootfs: "therealbobo/amazonlinux2022-image:5.15-x86_64-{{ version }}", arch: "x86_64"} # noqa: yaml[line-length]
- {name: "amazonlinux2023-6.1", kernel: "therealbobo/amazonlinux2023-kernel:6.1-x86_64-{{ version }}", rootfs: "therealbobo/amazonlinux2023-image:6.1-x86_64-{{ version }}", arch: "x86_64"} # noqa: yaml[line-length]
- {name: "amazonlinux2-4.19", kernel: "therealbobo/amazonlinux2-kernel:4.19-x86_64-{{ version }}", rootfs: "therealbobo/amazonlinux2-image:4.19-x86_64-{{ version }}", arch: "x86_64"}
- {name: "amazonlinux2-5.10", kernel: "therealbobo/amazonlinux2-kernel:5.10-x86_64-{{ version }}", rootfs: "therealbobo/amazonlinux2-image:5.10-x86_64-{{ version }}", arch: "x86_64"}
- {name: "amazonlinux2-5.15", kernel: "therealbobo/amazonlinux2-kernel:5.15-x86_64-{{ version }}", rootfs: "therealbobo/amazonlinux2-image:5.15-x86_64-{{ version }}", arch: "x86_64"}
- {name: "amazonlinux2-5.4", kernel: "therealbobo/amazonlinux2-kernel:5.4-x86_64-{{ version }}", rootfs: "therealbobo/amazonlinux2-image:5.4-x86_64-{{ version }}", arch: "x86_64"}
- {name: "archlinux-6.0", kernel: "therealbobo/archlinux-kernel:6.0-x86_64-{{ version }}", rootfs: "therealbobo/archlinux-image:6.0-x86_64-{{ version }}", arch: "x86_64"}
- {name: "centos-3.10", kernel: "therealbobo/centos-kernel:3.10-x86_64-{{ version }}", rootfs: "therealbobo/centos-image:3.10-x86_64-{{ version }}", arch: "x86_64"}
- {name: "centos-4.18", kernel: "therealbobo/centos-kernel:4.18-x86_64-{{ version }}", rootfs: "therealbobo/centos-image:4.18-x86_64-{{ version }}", arch: "x86_64"}
- {name: "centos-5.14", kernel: "therealbobo/centos-kernel:5.14-x86_64-{{ version }}", rootfs: "therealbobo/centos-image:5.14-x86_64-{{ version }}", arch: "x86_64"}
- {name: "fedora-5.17", kernel: "therealbobo/fedora-kernel:5.17-x86_64-{{ version }}", rootfs: "therealbobo/fedora-image:5.17-x86_64-{{ version }}", arch: "x86_64"}
- {name: "fedora-5.8", kernel: "therealbobo/fedora-kernel:5.8-x86_64-{{ version }}", rootfs: "therealbobo/fedora-image:5.8-x86_64-{{ version }}", arch: "x86_64"}
- {name: "fedora-6.2", kernel: "therealbobo/fedora-kernel:6.2-x86_64-{{ version }}", rootfs: "therealbobo/fedora-image:6.2-x86_64-{{ version }}", arch: "x86_64"}
- {name: "oraclelinux-3.10", kernel: "therealbobo/oraclelinux-kernel:3.10-x86_64-{{ version }}", rootfs: "therealbobo/oraclelinux-image:3.10-x86_64-{{ version }}", arch: "x86_64"}
- {name: "oraclelinux-4.14", kernel: "therealbobo/oraclelinux-kernel:4.14-x86_64-{{ version }}", rootfs: "therealbobo/oraclelinux-image:4.14-x86_64-{{ version }}", arch: "x86_64"}
- {name: "oraclelinux-5.15", kernel: "therealbobo/oraclelinux-kernel:5.15-x86_64-{{ version }}", rootfs: "therealbobo/oraclelinux-image:5.15-x86_64-{{ version }}", arch: "x86_64"}
- {name: "oraclelinux-5.4", kernel: "therealbobo/oraclelinux-kernel:5.4-x86_64-{{ version }}", rootfs: "therealbobo/oraclelinux-image:5.4-x86_64-{{ version }}", arch: "x86_64"}
- {name: "ubuntu-4.15", kernel: "therealbobo/ubuntu-kernel:4.15-x86_64-{{ version }}", rootfs: "therealbobo/ubuntu-image:4.15-x86_64-{{ version }}", arch: "x86_64"}
- {name: "ubuntu-6.3", kernel: "therealbobo/ubuntu-kernel:6.3-x86_64-{{ version }}", rootfs: "therealbobo/ubuntu-image:6.3-x86_64-{{ version }}", arch: "x86_64"}
- {name: "amazonlinux2022-5.15", kernel: "therealbobo/amazonlinux2022-kernel:5.15-aarch64-{{ version }}", rootfs: "therealbobo/amazonlinux2022-image:5.15-aarch64-{{ version }}", arch: "aarch64"} # noqa: yaml[line-length]
- {name: "amazonlinux2-5.4", kernel: "therealbobo/amazonlinux2-kernel:5.4-aarch64-{{ version }}", rootfs: "therealbobo/amazonlinux2-image:5.4-aarch64-{{ version }}", arch: "aarch64"}
- {name: "fedora-6.2", kernel: "therealbobo/fedora-kernel:6.2-aarch64-{{ version }}", rootfs: "therealbobo/fedora-image:6.2-aarch64-{{ version }}", arch: "aarch64"}
- {name: "oraclelinux-4.14", kernel: "therealbobo/oraclelinux-kernel:4.14-aarch64-{{ version }}", rootfs: "therealbobo/oraclelinux-image:4.14-aarch64-{{ version }}", arch: "aarch64"}
- {name: "oraclelinux-5.15", kernel: "therealbobo/oraclelinux-kernel:5.15-aarch64-{{ version }}", rootfs: "therealbobo/oraclelinux-image:5.15-aarch64-{{ version }}", arch: "aarch64"}
- {name: "ubuntu-6.3", kernel: "therealbobo/ubuntu-kernel:6.3-aarch64-{{ version }}", rootfs: "therealbobo/ubuntu-image:6.3-aarch64-{{ version }}", arch: "aarch64"}

builders:
- {name: "centos-builder", kernel: "weaveworks/ignite-kernel:5.14.16", rootfs: "therealbobo/builder:0.0.1-x86_64", arch: "x86_64"}
- {name: "fedora-builder", kernel: "weaveworks/ignite-kernel:5.14.16", rootfs: "therealbobo/modernprobe-builder:0.0.1-x86_64", arch: "x86_64"}
- {name: "centos-builder", kernel: "weaveworks/ignite-kernel:5.14.16", rootfs: "therealbobo/builder:0.0.1-aarch64", arch: "aarch64"}
- {name: "fedora-builder", kernel: "weaveworks/ignite-kernel:5.14.16", rootfs: "therealbobo/modernprobe-builder:0.0.1-aarch64", arch: "aarch64"}
- {name: "centos-builder", kernel: "weaveworks/ignite-kernel:5.14.16", rootfs: "therealbobo/builder:0.0.1-x86_64-{{ version }}", arch: "x86_64"}
- {name: "fedora-builder", kernel: "weaveworks/ignite-kernel:5.14.16", rootfs: "therealbobo/modernprobe-builder:0.0.1-x86_64-{{ version }}", arch: "x86_64"}
- {name: "centos-builder", kernel: "weaveworks/ignite-kernel:5.14.16", rootfs: "therealbobo/builder:0.0.1-aarch64-{{ version }}", arch: "aarch64"}
- {name: "fedora-builder", kernel: "weaveworks/ignite-kernel:5.14.16", rootfs: "therealbobo/modernprobe-builder:0.0.1-aarch64-{{ version }}", arch: "aarch64"}

output_dir: "~/ansible_output"
# Number of cpus.
Expand Down
Loading

0 comments on commit edb1f03

Please sign in to comment.