Skip to content

Build and Push Containers #13

Build and Push Containers

Build and Push Containers #13

name: Build and Push Containers
on:
workflow_dispatch:
inputs:
commit_sha:
description: "Specific Commit SHA (Required)"
required: true
release_tag:
description: "Release Tag (Optional)"
required: false
default: ""
build_agent:
description: "Build and push agent service"
type: boolean
default: true
build_ui_service:
description: "Build and push UI service"
type: boolean
default: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: nethermindeth/teeception
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- service: agent
dockerfile: agent.Dockerfile
condition: ${{ github.event.inputs.build_agent == 'true' }}
- service: ui_service
dockerfile: ui_service.Dockerfile
condition: ${{ github.event.inputs.build_ui_service == 'true' }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit_sha }}
if: ${{ matrix.condition }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
if: ${{ matrix.condition }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ matrix.condition }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ matrix.condition }}
- name: Set Tag Name
id: set_tag
run: echo "tag=${{ github.event.inputs.release_tag || github.event.inputs.commit_sha }}" >> $GITHUB_OUTPUT
if: ${{ matrix.condition }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
push: true
context: .
file: ${{ matrix.dockerfile }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.service }}:${{ steps.set_tag.outputs.tag }}
cache-from: type=gha,scope=${{ matrix.service }}
cache-to: type=gha,mode=max,scope=${{ matrix.service }}
if: ${{ matrix.condition }}