Skip to content

Merge branch 'main' into staging #942

Merge branch 'main' into staging

Merge branch 'main' into staging #942

name: Publish Images
on:
push:
branches: ["staging"]
tags:
- "*.*.*"
pull_request:
branches: ["staging"]
env:
REGISTRY: ghcr.io
permissions:
contents: read
packages: write
jobs:
build-and-push-api:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
platform: linux/amd64
platform_tag: linux-amd64
- runner: ubuntu-arm64-latest
platform: linux/arm64
platform_tag: linux-arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/tracecathq/tracecat
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/tracecathq/tracecat,push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=build-${{ matrix.platform_tag }}
cache-to: type=gha,scope=build-${{ matrix.platform_tag }},mode=max
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.platform_tag }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge-api:
needs: build-and-push-api
runs-on: ubuntu-latest
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/tracecathq/tracecat
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/tracecathq/tracecat@sha256:%s ' *) \
${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && '-t ghcr.io/tracecathq/tracecat:latest' || '' }}
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/tracecathq/tracecat:${{ steps.meta.outputs.version }}
build-and-push-ui:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
platform: linux/amd64
platform_tag: linux-amd64
- runner: ubuntu-arm64-latest
platform: linux/arm64
platform_tag: linux-arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/tracecathq/tracecat-ui
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
env:
NEXT_PUBLIC_API_URL: http://localhost:8000
NEXT_PUBLIC_APP_ENV: production
NEXT_PUBLIC_APP_URL: http://localhost:3000
NEXT_SERVER_API_URL: http://localhost:8000
NODE_ENV: production
with:
context: frontend
file: frontend/Dockerfile.prod
platforms: ${{ matrix.platform }}
build-args: |
NEXT_PUBLIC_API_URL=${{ env.NEXT_PUBLIC_API_URL }}
NEXT_PUBLIC_APP_ENV=${{ env.NEXT_PUBLIC_APP_ENV }}
NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }}
NEXT_SERVER_API_URL=${{ env.NEXT_SERVER_API_URL }}
NODE_ENV=${{ env.NODE_ENV }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/tracecathq/tracecat-ui,push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=build-${{ matrix.platform_tag }}
cache-to: type=gha,scope=build-${{ matrix.platform_tag }},mode=max
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: ui-digests-${{ matrix.platform_tag }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge-ui:
needs: build-and-push-ui
runs-on: ubuntu-latest
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: ui-digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/tracecathq/tracecat-ui
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/tracecathq/tracecat-ui@sha256:%s ' *) \
${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && '-t ghcr.io/tracecathq/tracecat-ui:latest' || '' }}
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/tracecathq/tracecat-ui:${{ steps.meta.outputs.version }}