# Builds the net-snmp base image used by the agent Dockerfile. # Only needs to run when the net-snmp version changes. # # Trigger manually or on changes to Dockerfile.netsnmp. name: Build net-snmp base image on: push: branches: [main] paths: [Dockerfile.netsnmp] workflow_dispatch: inputs: netsnmp_version: description: "Net-SNMP version to build" default: "5.9.5.2" required: true env: REGISTRY: ghcr.io IMAGE_NAME: towerops-app/netsnmp-alpine jobs: build: name: Build (${{ matrix.arch }}) runs-on: ${{ matrix.runner }} permissions: contents: read packages: write strategy: fail-fast: false matrix: include: - platform: linux/amd64 arch: amd64 runner: blacksmith-4vcpu-ubuntu-2404 - platform: linux/arm64 arch: arm64 runner: blacksmith-4vcpu-ubuntu-2404-arm steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Blacksmith Builder uses: useblacksmith/setup-docker-builder@v1 - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: useblacksmith/build-push-action@v2 with: context: . file: Dockerfile.netsnmp platforms: ${{ matrix.platform }} push: true provenance: false build-args: | NETSNMP_VERSION=${{ inputs.netsnmp_version || '5.9.5.2' }} tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.netsnmp_version || '5.9.5.2' }}-${{ matrix.arch }} manifest: name: Create Manifest needs: build runs-on: blacksmith-4vcpu-ubuntu-2404 permissions: contents: read packages: write steps: - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Create multi-arch manifest run: | VERSION="${{ inputs.netsnmp_version || '5.9.5.2' }}" IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" docker buildx imagetools create -t ${IMAGE}:${VERSION} \ ${IMAGE}:${VERSION}-amd64 \ ${IMAGE}:${VERSION}-arm64 docker buildx imagetools create -t ${IMAGE}:latest \ ${IMAGE}:${VERSION}-amd64 \ ${IMAGE}:${VERSION}-arm64 - name: Summary run: | echo "### net-snmp base image built" >> $GITHUB_STEP_SUMMARY echo "Version: ${{ inputs.netsnmp_version || '5.9.5.2' }}" >> $GITHUB_STEP_SUMMARY echo "Image: \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.netsnmp_version || '5.9.5.2' }}\`" >> $GITHUB_STEP_SUMMARY