Skip to content

Instantly share code, notes, and snippets.

@badnetmask
Created February 4, 2025 12:07
Show Gist options
  • Select an option

  • Save badnetmask/d2d73fdcae4c67d36bf24723c996d310 to your computer and use it in GitHub Desktop.

Select an option

Save badnetmask/d2d73fdcae4c67d36bf24723c996d310 to your computer and use it in GitHub Desktop.
name: EE build dual node
on:
push:
branches:
- main
# Uncomment to run only when specific files change
# paths:
# - '**/ansible-navigator.yaml'
# - '**/execution-environment.yml'
env:
# Set this to the public IP or hostname of your registry,
# whichever you use to reach it from your desktop/laptop
FORGEJO_HOST: forgejo.lab.home.arpa
CONTAINER_NAME: homelab-ee-dual
jobs:
build-and-push-arch:
runs-on: catthehacker-${{ matrix.arch }}
strategy:
matrix:
arch: [amd64, arm64]
environment: deploy
steps:
- name: Prepare environment variables
run: |
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
echo REGISTRY=${{ env.FORGEJO_HOST }} >> $GITHUB_ENV
- name: Checkout the repo
uses: actions/checkout@v4
- name: Install requirements
run: |
pip install -r requirements.txt
- name: Generate the Ansible Builder context
run: |
ansible-builder create -v 3
- name: Login to the registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.PACKAGE_TOKEN }}
# Due to a (possible) bug in either the buildx action
# or the underlying buildx itself while running on Docker-in-Docker,
# we need to set network=host and hardcode the DNS servers
# https://github.com/tailscale/github-action/issues/101
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
config-inline: |
[dns]
nameservers = ["192.168.1.1", "192.168.1.2"]
[registry."${{ env.REGISTRY }}"]
ca=["/usr/local/share/ca-certificates/homelab-ca.crt"]
- name: Build and push
uses: docker/build-push-action@v6
with:
context: context
push: true
provenance: false
tags: ${{ env.REGISTRY }}/${{ github.actor }}/${{ 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=${{ env.FORGEJO_HOST }} >> $GITHUB_ENV
echo ${{ secrets.PACKAGE_TOKEN }} | docker login ${{ env.FORGEJO_HOST }} -u ${GITHUB_ACTOR} --password-stdin
docker manifest create ${{ env.FORGEJO_HOST }}/${GITHUB_ACTOR}/${{ env.CONTAINER_NAME }}:latest ${{ env.FORGEJO_HOST }}/${GITHUB_ACTOR}/${{ env.CONTAINER_NAME }}-amd64:latest ${{ env.FORGEJO_HOST }}/${GITHUB_ACTOR}/${{ env.CONTAINER_NAME }}-arm64:latest
docker manifest push ${{ env.FORGEJO_HOST }}/${GITHUB_ACTOR}/${{ env.CONTAINER_NAME }}:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment