Merge pull request #58 from Lumen-Labs/development #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 "action@github.com" | |
| 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 }} |