Skip to content

Merge pull request #254 from rapidaai/chore/unittest-fixes #73

Merge pull request #254 from rapidaai/chore/unittest-fixes

Merge pull request #254 from rapidaai/chore/unittest-fixes #73

name: Build and Push Docker Images
on:
push:
branches:
- main
- saas
paths:
- "api/web-api/**"
- "api/integration-api/**"
- "api/endpoint-api/**"
- "api/assistant-api/**"
- "cmd/**"
- "pkg/**"
- "ui/**"
- "docker/web-api/**"
- "docker/integration-api/**"
- "docker/endpoint-api/**"
- "docker/assistant-api/**"
- "docker/ui/**"
- "go.mod"
- "go.sum"
- ".github/actions/docker-build/action.yml"
- ".github/workflows/docker-publish.yml"
workflow_dispatch:
inputs:
images:
description: "Images to publish: all or comma-separated web-api,integration-api,endpoint-api,assistant-api,ui"
required: false
default: all
permissions:
contents: read
env:
DOCKER_REGISTRY: rapidaai
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
web-api: ${{ steps.set.outputs.web-api }}
integration-api: ${{ steps.set.outputs.integration-api }}
endpoint-api: ${{ steps.set.outputs.endpoint-api }}
assistant-api: ${{ steps.set.outputs.assistant-api }}
ui: ${{ steps.set.outputs.ui }}
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Detect changed images
uses: dorny/paths-filter@0e4a8c6effa4802afeda77dc8d303f8176d7dfad
id: filter
if: github.event_name == 'push'
with:
filters: |
web-api:
- "api/web-api/**"
- "cmd/web/**"
- "pkg/**"
- "docker/web-api/**"
- "go.mod"
- "go.sum"
integration-api:
- "api/integration-api/**"
- "cmd/integration/**"
- "pkg/**"
- "docker/integration-api/**"
- "go.mod"
- "go.sum"
endpoint-api:
- "api/endpoint-api/**"
- "cmd/endpoint/**"
- "pkg/**"
- "docker/endpoint-api/**"
- "go.mod"
- "go.sum"
assistant-api:
- "api/assistant-api/**"
- "cmd/assistant/**"
- "pkg/**"
- "docker/assistant-api/**"
- "go.mod"
- "go.sum"
ui:
- "ui/**"
- "docker/ui/**"
- name: Set publish targets
id: set
run: |
set -euo pipefail
select_image() {
local name="$1"
if [ "$PUBLISH_ALL" = "true" ] || printf '%s' "$INPUT" | tr ',' '\n' | grep -qx "$name"; then
echo "${name}=true"
else
echo "${name}=false"
fi
}
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
INPUT="${{ inputs.images }}"
if [ -z "$INPUT" ] || [ "$INPUT" = "all" ]; then
PUBLISH_ALL=true
else
PUBLISH_ALL=false
fi
{
select_image web-api
select_image integration-api
select_image endpoint-api
select_image assistant-api
select_image ui
} >> "$GITHUB_OUTPUT"
else
{
echo "web-api=${{ steps.filter.outputs.web-api }}"
echo "integration-api=${{ steps.filter.outputs.integration-api }}"
echo "endpoint-api=${{ steps.filter.outputs.endpoint-api }}"
echo "assistant-api=${{ steps.filter.outputs.assistant-api }}"
echo "ui=${{ steps.filter.outputs.ui }}"
} >> "$GITHUB_OUTPUT"
fi
meta:
name: Extract metadata
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.meta.outputs.sha_short }}
date: ${{ steps.meta.outputs.date }}
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Resolve tags
id: meta
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
echo "date=$(date +'%Y%m%d')" >> "$GITHUB_OUTPUT"
web-api:
name: Build web-api
needs:
- changes
- meta
if: needs.changes.outputs.web-api == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Build and push web-api
uses: ./.github/actions/docker-build
with:
context: .
dockerfile: ./docker/web-api/Dockerfile
push: "true"
tags: |
${{ env.DOCKER_REGISTRY }}/web-api:latest
${{ env.DOCKER_REGISTRY }}/web-api:${{ needs.meta.outputs.sha_short }}
${{ env.DOCKER_REGISTRY }}/web-api:${{ needs.meta.outputs.date }}
cache-scope: web-api
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
integration-api:
name: Build integration-api
needs:
- changes
- meta
if: needs.changes.outputs.integration-api == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Build and push integration-api
uses: ./.github/actions/docker-build
with:
context: .
dockerfile: ./docker/integration-api/Dockerfile
push: "true"
tags: |
${{ env.DOCKER_REGISTRY }}/integration-api:latest
${{ env.DOCKER_REGISTRY }}/integration-api:${{ needs.meta.outputs.sha_short }}
${{ env.DOCKER_REGISTRY }}/integration-api:${{ needs.meta.outputs.date }}
cache-scope: integration-api
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
endpoint-api:
name: Build endpoint-api
needs:
- changes
- meta
if: needs.changes.outputs.endpoint-api == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Build and push endpoint-api
uses: ./.github/actions/docker-build
with:
context: .
dockerfile: ./docker/endpoint-api/Dockerfile
push: "true"
tags: |
${{ env.DOCKER_REGISTRY }}/endpoint-api:latest
${{ env.DOCKER_REGISTRY }}/endpoint-api:${{ needs.meta.outputs.sha_short }}
${{ env.DOCKER_REGISTRY }}/endpoint-api:${{ needs.meta.outputs.date }}
cache-scope: endpoint-api
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
assistant-api:
name: Build assistant-api
needs:
- changes
- meta
if: needs.changes.outputs.assistant-api == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Build and push assistant-api
uses: ./.github/actions/docker-build
with:
context: .
dockerfile: ./docker/assistant-api/Dockerfile
push: "true"
tags: |
${{ env.DOCKER_REGISTRY }}/assistant-api:latest
${{ env.DOCKER_REGISTRY }}/assistant-api:${{ needs.meta.outputs.sha_short }}
${{ env.DOCKER_REGISTRY }}/assistant-api:${{ needs.meta.outputs.date }}
cache-scope: assistant-api
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
ui:
name: Build ui
needs:
- changes
- meta
if: needs.changes.outputs.ui == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Build and push ui
uses: ./.github/actions/docker-build
with:
context: .
dockerfile: ./docker/ui/Dockerfile
push: "true"
build-args: EDITION=community
tags: |
${{ env.DOCKER_REGISTRY }}/ui:latest
${{ env.DOCKER_REGISTRY }}/ui:${{ needs.meta.outputs.sha_short }}
${{ env.DOCKER_REGISTRY }}/ui:${{ needs.meta.outputs.date }}
cache-scope: ui
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
summary:
name: Summary
needs:
- meta
- web-api
- integration-api
- endpoint-api
- assistant-api
- ui
if: always()
runs-on: ubuntu-latest
steps:
- name: Write summary
run: |
{
echo "## Docker Images Published"
echo ""
echo "| Image | Result | Tags |"
echo "|-------|--------|------|"
echo "| web-api | ${{ needs.web-api.result }} | latest, ${{ needs.meta.outputs.sha_short }}, ${{ needs.meta.outputs.date }} |"
echo "| integration-api | ${{ needs.integration-api.result }} | latest, ${{ needs.meta.outputs.sha_short }}, ${{ needs.meta.outputs.date }} |"
echo "| endpoint-api | ${{ needs.endpoint-api.result }} | latest, ${{ needs.meta.outputs.sha_short }}, ${{ needs.meta.outputs.date }} |"
echo "| assistant-api | ${{ needs.assistant-api.result }} | latest, ${{ needs.meta.outputs.sha_short }}, ${{ needs.meta.outputs.date }} |"
echo "| ui | ${{ needs.ui.result }} | latest, ${{ needs.meta.outputs.sha_short }}, ${{ needs.meta.outputs.date }} |"
} >> "$GITHUB_STEP_SUMMARY"