2025-07-14 01:06:06 +02:00
|
|
|
# Workflow name
|
|
|
|
|
name: Build and Push Ansible Container
|
|
|
|
|
|
|
|
|
|
# Run-name for each workflow run
|
2025-07-13 23:49:10 +02:00
|
|
|
run-name: Build and Push Ansible Container
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches:
|
|
|
|
|
- main
|
|
|
|
|
paths:
|
2025-07-14 01:06:06 +02:00
|
|
|
- 'containers/ansible/**'
|
2025-07-14 00:25:58 +02:00
|
|
|
- '.forgejo/workflows/ansible.yml'
|
2025-07-13 23:49:10 +02:00
|
|
|
workflow_dispatch: {}
|
|
|
|
|
schedule:
|
2025-07-14 00:45:11 +02:00
|
|
|
- cron: '0 20 * * 5' # Runs every Friday at 8 PM UTC
|
2025-07-13 23:49:10 +02:00
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
build-and-push:
|
|
|
|
|
strategy:
|
|
|
|
|
matrix:
|
|
|
|
|
arch: [ amd64, arm64 ]
|
2025-07-14 00:40:00 +02:00
|
|
|
runs-on: ${{ matrix.arch }}
|
2025-07-21 00:36:04 +02:00
|
|
|
container:
|
2025-07-21 00:36:52 +02:00
|
|
|
image: ghcr.io/catthehacker/ubuntu:act-22.04
|
2025-07-13 23:49:10 +02:00
|
|
|
steps:
|
2025-07-14 00:45:11 +02:00
|
|
|
- name: Checkout repository
|
2025-07-13 23:49:10 +02:00
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
2025-07-14 00:45:11 +02:00
|
|
|
- name: Set up Docker Buildx
|
2025-07-13 23:49:10 +02:00
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
2025-07-21 00:38:01 +02:00
|
|
|
- name: Login to Forgejo Container Registry
|
2025-07-13 23:49:10 +02:00
|
|
|
uses: docker/login-action@v3
|
|
|
|
|
with:
|
2025-07-21 00:38:01 +02:00
|
|
|
registry: ${{ vars.REGISTRY }}
|
2025-07-21 00:53:04 +02:00
|
|
|
username: ${{ github.actor }}
|
|
|
|
|
password: ${{ secrets.PACKAGE_TOKEN }}
|
2025-07-13 23:49:10 +02:00
|
|
|
|
|
|
|
|
- name: Build and push (${{ matrix.arch }})
|
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
|
with:
|
2025-07-14 01:06:06 +02:00
|
|
|
context: ./containers/ansible/
|
|
|
|
|
file: ./containers/ansible/Dockerfile
|
2025-07-13 23:49:10 +02:00
|
|
|
platforms: linux/${{ matrix.arch }}
|
|
|
|
|
push: true
|
|
|
|
|
tags: |
|
2025-07-14 01:06:06 +02:00
|
|
|
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:${{ matrix.arch }}-latest
|
2025-07-13 23:49:10 +02:00
|
|
|
|
|
|
|
|
manifest:
|
|
|
|
|
needs: build-and-push
|
2025-07-14 01:06:06 +02:00
|
|
|
runs-on: amd64
|
|
|
|
|
services:
|
|
|
|
|
dind:
|
|
|
|
|
image: docker:dind
|
|
|
|
|
privileged: true
|
|
|
|
|
env:
|
|
|
|
|
DOCKER_HOST: tcp://dind:2375
|
2025-07-13 23:49:10 +02:00
|
|
|
steps:
|
2025-07-14 01:06:06 +02:00
|
|
|
- name: Wait for Docker to start
|
2025-07-14 00:07:38 +02:00
|
|
|
run: |
|
2025-07-14 01:06:06 +02:00
|
|
|
i=0
|
2025-07-21 00:35:16 +02:00
|
|
|
while ! docker info >/dev/null 2>&1; do
|
2025-07-14 01:06:06 +02:00
|
|
|
i=$((i+1))
|
|
|
|
|
if [ $i -ge 15 ]; then
|
|
|
|
|
echo "Docker did not start within 15 seconds"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
echo "Waiting for Docker to start..."
|
|
|
|
|
sleep 1
|
|
|
|
|
done
|
2025-07-14 00:07:38 +02:00
|
|
|
|
2025-07-13 23:49:10 +02:00
|
|
|
- name: Login to Forgejo Registry
|
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
|
with:
|
|
|
|
|
registry: ${{ secrets.CI_REGISTRY }}
|
|
|
|
|
username: ${{ secrets.CI_REGISTRY_USER }}
|
|
|
|
|
password: ${{ secrets.CI_TOKEN }}
|
|
|
|
|
|
|
|
|
|
- name: Create and push multi-arch manifest
|
|
|
|
|
run: |
|
2025-07-14 01:06:06 +02:00
|
|
|
docker manifest create ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:latest \
|
|
|
|
|
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:amd64-latest \
|
|
|
|
|
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:arm64-latest
|
|
|
|
|
docker manifest push ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:latest
|