containers/.forgejo/workflows/ansible.yml

67 lines
2 KiB
YAML
Raw Permalink Normal View History

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
2025-07-21 01:09:13 +02:00
env:
CONTAINER_NAME: ansible
2025-07-21 01:10:13 +02:00
# USER: ${{ github.actor }}
USER: hbms
2025-07-21 01:09:13 +02:00
2025-07-13 23:49:10 +02:00
jobs:
2025-07-21 01:33:59 +02:00
build-and-push-arch:
runs-on: ${{ matrix.arch }}
strategy:
matrix:
arch: [ amd64, arm64 ]
container:
image: ghcr.io/catthehacker/ubuntu:act-22.04
2025-07-13 23:49:10 +02:00
steps:
2025-07-21 01:33:59 +02:00
- name: Prepare environment variables
run: |
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
echo REGISTRY=${{ vars.REGISTRY }} >> $GITHUB_ENV
2025-07-13 23:49:10 +02:00
2025-07-21 01:33:59 +02:00
- name: Checkout the repo
uses: actions/checkout@v4
2025-07-13 23:49:10 +02:00
2025-07-21 01:33:59 +02:00
- name: Login to the registry
2025-07-13 23:49:10 +02:00
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY }}
2025-07-21 01:10:13 +02:00
username: ${{ env.USER }}
password: ${{ secrets.PACKAGE_TOKEN }}
2025-07-13 23:49:10 +02:00
2025-07-21 01:09:13 +02:00
- name: Build and push
uses: docker/build-push-action@v6
2025-07-13 23:49:10 +02:00
with:
2025-07-21 01:35:08 +02:00
context: ./containers/ansible/
file: ./containers/ansible/Dockerfile
2025-07-13 23:49:10 +02:00
push: true
2025-07-21 01:09:13 +02:00
provenance: false
2025-07-21 01:33:59 +02:00
tags: ${{ vars.REGISTRY }}/${{ env.USER }}/${{ env.CONTAINER_NAME }}-${{ matrix.arch }}:latest
merge-images-via-manifest:
2025-07-21 01:34:22 +02:00
runs-on: amd64
2025-07-21 01:33:59 +02:00
needs: build-and-push-arch
container:
image: ghcr.io/catthehacker/ubuntu:act-22.04
2025-07-21 01:33:59 +02:00
steps:
- name: Generate and push multi-arch manifest
run: |
echo REGISTRY=${{ vars.REGISTRY }} >> $GITHUB_ENV
echo ${{ secrets.PACKAGE_TOKEN }} | docker login ${{ vars.REGISTRY }} -u ${USER} --password-stdin
docker manifest create ${{ vars.REGISTRY }}/${USER}/${{ env.CONTAINER_NAME }}:latest ${{ vars.REGISTRY }}/${USER}/${{ env.CONTAINER_NAME }}-amd64:latest ${{ vars.REGISTRY }}/${USER}/${{ env.CONTAINER_NAME }}-arm64:latest
docker manifest push ${{ vars.REGISTRY }}/${USER}/${{ env.CONTAINER_NAME }}:latest