fix(k8s): use correct GitHub org berget-ai for container registry #1
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 Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*.*.*" | |
| paths-ignore: | |
| - "k8s/**" | |
| - "*.md" | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "k8s/**" | |
| - "*.md" | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure Git | |
| run: | | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| - 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: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Bump version (main branch only) | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| id: bump_version | |
| run: | | |
| npm version prerelease --preid=rc --no-git-tag-version | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| git add package.json | |
| git commit -m "chore: bump version to $VERSION [skip ci]" | |
| git push | |
| - name: Get version from package.json | |
| id: get_version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Get PR version | |
| if: github.event_name == 'pull_request' | |
| id: pr_version | |
| run: | | |
| BASE_VERSION=$(node -p "require('./package.json').version.split('-')[0]") | |
| VERSION="${BASE_VERSION}-pr-${{ github.event.pull_request.number }}" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Get tag version | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| id: tag_version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| echo "VERSION=${{ steps.pr_version.outputs.VERSION }}" >> $GITHUB_OUTPUT | |
| elif [ "${{ startsWith(github.ref, 'refs/tags/v') }}" == "true" ]; then | |
| echo "VERSION=${{ steps.tag_version.outputs.VERSION }}" >> $GITHUB_OUTPUT | |
| elif [ -n "${{ steps.bump_version.outputs.VERSION }}" ]; then | |
| echo "VERSION=${{ steps.bump_version.outputs.VERSION }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ghcr.io/berget-ai/memory:${{ steps.version.outputs.VERSION }} | |
| cache-from: type=gha,scope=memory | |
| cache-to: type=gha,mode=max,scope=memory |