From 5297197289ac34a3994b3a6d70aefe77b5c7e200 Mon Sep 17 00:00:00 2001 From: Xaver Russ Date: Mon, 21 Jul 2025 01:33:59 +0200 Subject: [PATCH] ansible split build --- .forgejo/workflows/ansible.yml | 38 ++++++++++------ .forgejo/workflows/ansible.yml-old | 67 ----------------------------- .forgejo/workflows/ansible.yml-qemu | 50 +++++++++++++++++++++ 3 files changed, 76 insertions(+), 79 deletions(-) delete mode 100644 .forgejo/workflows/ansible.yml-old create mode 100644 .forgejo/workflows/ansible.yml-qemu diff --git a/.forgejo/workflows/ansible.yml b/.forgejo/workflows/ansible.yml index 347e726..68b3cbd 100644 --- a/.forgejo/workflows/ansible.yml +++ b/.forgejo/workflows/ansible.yml @@ -20,19 +20,23 @@ env: USER: hbms jobs: - build-and-push: - # runs-on: docker - runs-on: arm64 + build-and-push-arch: + runs-on: ${{ matrix.arch }} + strategy: + matrix: + arch: [ amd64, arm64 ] container: image: ghcr.io/catthehacker/ubuntu:act-22.04 steps: - - name: Checkout repository + - name: Prepare environment variables + run: | + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + echo REGISTRY=${{ vars.REGISTRY }} >> $GITHUB_ENV + + - name: Checkout the repo uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Forgejo Container Registry + - name: Login to the registry uses: docker/login-action@v3 with: registry: ${{ vars.REGISTRY }} @@ -42,9 +46,19 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: - context: ./containers/ansible/ - file: ./containers/ansible/Dockerfile + context: context push: true provenance: false - platforms: linux/amd64, linux/arm64 - tags: ${{ vars.REGISTRY }}/${{ env.USER }}/${{ env.CONTAINER_NAME }}:latest + tags: ${{ vars.REGISTRY }}/${{ env.USER }}/${{ env.CONTAINER_NAME }}-${{ matrix.arch }}:latest + + merge-images-via-manifest: + runs-on: catthehacker-amd64 + needs: build-and-push-arch + environment: deploy + 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 diff --git a/.forgejo/workflows/ansible.yml-old b/.forgejo/workflows/ansible.yml-old deleted file mode 100644 index 216176f..0000000 --- a/.forgejo/workflows/ansible.yml-old +++ /dev/null @@ -1,67 +0,0 @@ -# Workflow name -name: Build and Push Ansible Container - -# Run-name for each workflow run -run-name: Build and Push Ansible Container -on: - push: - branches: - - main - paths: - - 'containers/ansible/**' - - '.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: - image: ghcr.io/catthehacker/ubuntu:act-22.04 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Forgejo Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ vars.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.PACKAGE_TOKEN }} - - - name: Build and push (${{ matrix.arch }}) - uses: docker/build-push-action@v5 - with: - context: ./containers/ansible/ - file: ./containers/ansible/Dockerfile - platforms: linux/${{ matrix.arch }} - push: true - tags: | - ${{ vars.REGISTRY }}/${{ github.actor }}/ansible:${{ matrix.arch }}-latest - - manifest: - needs: build-and-push - runs-on: amd64 - container: - image: ghcr.io/catthehacker/ubuntu:act-22.04 - steps: - - name: Login to Forgejo Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ vars.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.PACKAGE_TOKEN }} - - - name: Create and push multi-arch manifest - run: | - docker manifest create ${{ vars.REGISTRY }}/${{ github.actor }}/ansible:latest \ - --amend ${{ vars.REGISTRY }}/${{ github.actor }}/ansible:amd64-latest \ - --amend ${{ vars.REGISTRY }}/${{ github.actor }}/ansible:arm64-latest - docker manifest push ${{ vars.REGISTRY }}/${{ github.actor }}/ansible:latest diff --git a/.forgejo/workflows/ansible.yml-qemu b/.forgejo/workflows/ansible.yml-qemu new file mode 100644 index 0000000..347e726 --- /dev/null +++ b/.forgejo/workflows/ansible.yml-qemu @@ -0,0 +1,50 @@ +# Workflow name +name: Build and Push Ansible Container + +# Run-name for each workflow run +run-name: Build and Push Ansible Container +on: + push: + branches: + - main + paths: + - 'containers/ansible/**' + - '.forgejo/workflows/ansible.yml' + workflow_dispatch: {} + schedule: + - cron: '0 20 * * 5' # Runs every Friday at 8 PM UTC + +env: + CONTAINER_NAME: ansible + # USER: ${{ github.actor }} + USER: hbms + +jobs: + build-and-push: + # runs-on: docker + runs-on: arm64 + container: + image: ghcr.io/catthehacker/ubuntu:act-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Forgejo Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.REGISTRY }} + username: ${{ env.USER }} + password: ${{ secrets.PACKAGE_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./containers/ansible/ + file: ./containers/ansible/Dockerfile + push: true + provenance: false + platforms: linux/amd64, linux/arm64 + tags: ${{ vars.REGISTRY }}/${{ env.USER }}/${{ env.CONTAINER_NAME }}:latest