Skip to content

feat: add new ansible build matrix #7

feat: add new ansible build matrix

feat: add new ansible build matrix #7

Workflow file for this run

name: Build docker images
on:
push:
jobs:
matrix:
name: Compute build matrix from json file
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- id: matrix
run: |
MATRIX=$(echo $(cat .github/workflows/matrix.json) | sed 's/ //g' )
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
build:
needs: [ matrix ]
runs-on: ubuntu-latest
name: Build ansible ${{ matrix.versions.ansible }} docker image
strategy:
matrix:
versions: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
# This is not required but recommended using it to be able to build multi-platform images, export cache, etc.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Allows to build arm64 images
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Build Docker images
uses: docker/build-push-action@v6
with:
build-args: |
ANSIBLE_VERSION=${{ matrix.versions.ansible }}
outputs: type=docker,dest=/tmp/image.tar
platforms: |
linux/amd64
linux/arm64
tags: |
ansible-${{ matrix.versions.ansible }}
- name: Export image to github artifact
uses: actions/upload-artifact@v4
with:
retention-days: 1
compression-level: 0
name: ansible-${{ matrix.versions.ansible }}
path: /tmp/image.tar
overwrite: true
test:
needs: [ build ]
runs-on: ubuntu-latest
strategy:
matrix:
cfg: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Download docker image
uses: actions/download-artifact@v4
with:
name: ansible-${{ matrix.versions.ansible }}
path: /tmp
- name: Test ansible version
run:
docker run ansible-${{ matrix.versions.ansible }} ansible-community --version | grep 'Ansible community version ${{ matrix.versions.ansible }}'
deploy:
needs: [ test ]
runs-on: ubuntu-latest
strategy:
matrix:
cfg: ${{ fromJson(needs.matrix.outputs.matrix) }}
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
packages: write
contents: read
steps:
- name: Download docker image
uses: actions/download-artifact@v4
with:
name: ansible-${{ matrix.versions.ansible }}
path: /tmp
- name: Load image
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: Login to Amazon ECR
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${REPOSITORY_PATH}
env:
REPOSITORY_PATH: ${{ secrets.PUBLIC_RUNNER_ANSIBLE_ECR_REPOSITORY_URL }}
- name: Log in to Github Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# TODO Re-tag images
# TODO Push