Skip to content

BrainAPI is a knowledge graph–powered AI memory layer that transforms unstructured data into structured knowledge, enabling intelligent search, recommendations, and contextual memory for AI agents and applications.

ci: add container build workflow for main and development

Cursor Agentb3aa9d8d37a1
diff --git a/.github/workflows/build-container.yaml b/.github/workflows/build-container.yaml
new file mode 100644
index 0000000..ff22a76
--- /dev/null
+++ b/.github/workflows/build-container.yaml
@@ -0,0 +1,85 @@
+name: Build and Push Container
+
+on:
+ push:
+ branches:
+ - main
+ - development
+
+jobs:
+ build-and-push:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ packages: write
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.11"
+
+ - name: Install Poetry
+ run: pip install poetry==2.1.3
+
+ - name: Verify lockfile matches pyproject.toml
+ run: poetry check --lock
+
+ - name: Get version
+ id: version
+ run: echo "VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')" >> $GITHUB_OUTPUT
+
+ - 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: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GHCR_TOKEN }}
+
+ - name: Build and push Docker image (main)
+ if: github.ref == 'refs/heads/main'
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ghcr.io/lumen-labs/brainapi:v${{ steps.version.outputs.VERSION }}
+ ghcr.io/lumen-labs/brainapi:latest
+ build-args: |
+ BUILD_DATE=${{ github.event.head_commit.timestamp }}
+ BUILD_SHA=${{ github.sha }}
+ CACHE_BUST=${{ github.run_number }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Build and push Docker image (development)
+ if: github.ref == 'refs/heads/development'
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ghcr.io/lumen-labs/brainapi:development
+ ghcr.io/lumen-labs/brainapi:v${{ steps.version.outputs.VERSION }}-development
+ build-args: |
+ BUILD_DATE=${{ github.event.head_commit.timestamp }}
+ BUILD_SHA=${{ github.sha }}
+ CACHE_BUST=${{ github.run_number }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Create Git tag (only on main branch)
+ if: github.ref == 'refs/heads/main'
+ run: |
+ git config --local user.email "[email protected]"
+ git config --local user.name "GitHub Action"
+ git tag -a v${{ steps.version.outputs.VERSION }} -m "Release v${{ steps.version.outputs.VERSION }}"
+ git push origin v${{ steps.version.outputs.VERSION }}