Skip to content

Merge branch 'develop' #619

Merge branch 'develop'

Merge branch 'develop' #619

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- main
- develop
tags:
- 'v*'
pull_request:
branches:
- main
- develop
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# First job: Build and test the image before pushing
build-and-test:
name: Build and Test Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build Docker image for testing
run: |
docker build -t osa-test:ci -f ./deploy/Dockerfile --build-arg GIT_COMMIT=${{ github.sha }} .
- name: Smoke test - Start container
run: |
docker run -d --name osa-test \
-p 38528:38528 \
-e REQUIRE_API_AUTH=false \
-e OPENROUTER_API_KEY=test-key-for-ci \
osa-test:ci
- name: Wait for container to be healthy
run: |
echo "Waiting for container to initialize..."
for i in {1..60}; do
if curl -sf http://localhost:38528/health > /dev/null 2>&1; then
echo "Container is healthy after $i seconds"
exit 0
fi
sleep 1
done
echo "Container failed to become healthy within 60 seconds"
docker logs osa-test
exit 1
- name: Smoke test - Check container health status
run: |
STATUS=$(docker inspect --format='{{.State.Health.Status}}' osa-test 2>/dev/null || echo "no-healthcheck")
echo "Container health status: $STATUS"
if [ "$STATUS" = "unhealthy" ]; then
echo "Container is unhealthy! Logs:"
docker logs osa-test
exit 1
fi
- name: Cleanup test container
if: always()
run: |
docker stop osa-test || true
docker rm osa-test || true
# Second job: Push to registry (on main, develop, and tags - not PRs)
build-and-push:
name: Build and Push to GHCR
needs: build-and-test
# Push on main, develop, or tags - skip for PRs
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Branch-based tags
type=ref,event=branch
# Tag-based tags (v1.0.0 -> 1.0.0)
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Latest tag for main branch
type=raw,value=latest,enable={{is_default_branch}}
# Dev tag for develop branch
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/develop' }}
# Commit SHA for traceability
type=sha,prefix=sha-
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./deploy/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_COMMIT=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
run: echo "${{ steps.meta.outputs.tags }}"