containers/.forgejo/workflows/ansible.yml
Xaver Russ 9e03158f81
Some checks failed
/ build-and-push (amd64) (push) Failing after 2m25s
/ build-and-push (arm64) (push) Failing after 1m55s
/ manifest (push) Has been skipped
more tests
2025-07-14 00:45:11 +02:00

82 lines
3.3 KiB
YAML

run-name: Build and Push Ansible Container
on:
push:
branches:
- main
paths:
- 'containers/${{ github.workflow }}/**' # This path will look for 'containers/Build and Push Ansible Container/**'
- '.forgejo/workflows/ansible.yml'
workflow_dispatch: {}
schedule:
- cron: '0 20 * * 5' # Runs every Friday at 8 PM UTC
jobs:
build-and-push:
strategy:
matrix:
arch: [ amd64, arm64 ]
runs-on: ${{ matrix.arch }}
container:
# Use a more suitable base image for package management and common tools.
# Debian is often a good balance between size and available packages.
# You're using `apk` (Alpine Linux package manager) in an Ubuntu container, which will fail.
image: debian:stable-slim # or debian:bookworm-slim, or even a specific Node.js image if you mainly need Node.js
steps:
- name: Install build dependencies (apt)
run: |
# Use apt for Debian/Ubuntu based images
apt-get update
apt-get install -y nodejs npm git bash ca-certificates curl
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Forgejo Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.CI_REGISTRY }}
username: ${{ secrets.CI_REGISTRY_USER }}
password: ${{ secrets.CI_TOKEN }}
# Removed the `cd` step as `context` and `file` can handle the path directly.
- name: Build and push (${{ matrix.arch }})
uses: docker/build-push-action@v5
with:
context: ./containers/${{ github.workflow }}/ # Relative to the checkout root
file: ./containers/${{ github.workflow }}/Dockerfile # Relative to the checkout root
platforms: linux/${{ matrix.arch }}
push: true
tags: |
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:${{ matrix.arch }}-latest
cache-from: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:buildcache-${{ matrix.arch }} # Add caching
cache-to: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:buildcache-${{ matrix.arch }},mode=max # Add caching
manifest:
needs: build-and-push
runs-on: ubuntu-latest # or amd64 if you have a specific AMD64 runner for manifest creation
steps:
- name: Install Docker CLI
run: |
# Ensure docker CLI is available in the runner environment for `docker manifest`
# Most `ubuntu-latest` runners already have it, but explicit is better.
sudo apt-get update
sudo apt-get install -y docker-ce-cli # Install only the client if the runner is not dind
- 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: |
# Use the explicit "docker" command which should be available
docker manifest create ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:latest \
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:amd64-latest \
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:arm64-latest
docker manifest push ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:latest