build-images v4.0.0 #1
Workflow file for this run
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-images | |
| run-name: build-images ${{ github.event.release.tag_name }} | |
| on: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| prepare: | |
| if: ${{ github.event_name == 'release' }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.release_tag.outputs.tag }} | |
| version: ${{ steps.release_tag.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Resolve release tag & version | |
| id: release_tag | |
| run: | | |
| git fetch --tags --force | |
| TAG="${{ github.event.release.tag_name }}" | |
| if [ -z "$TAG" ]; then | |
| echo "No Git tag found to check out" >&2 | |
| exit 1 | |
| fi | |
| VER_NO_V="${TAG#v}" | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| echo "version=$VER_NO_V" >> $GITHUB_OUTPUT | |
| build-image: | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: rag-backend | |
| dockerfile: services/rag-backend/Dockerfile | |
| - name: admin-backend | |
| dockerfile: services/admin-backend/Dockerfile | |
| - name: document-extractor | |
| dockerfile: services/document-extractor/Dockerfile | |
| - name: mcp-server | |
| dockerfile: services/mcp-server/Dockerfile | |
| - name: frontend | |
| dockerfile: services/frontend/apps/chat-app/Dockerfile | |
| - name: admin-frontend | |
| dockerfile: services/frontend/apps/admin-app/Dockerfile | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NS: ${{ github.repository }} | |
| VERSION: ${{ needs.prepare.outputs.version }} | |
| TAG: ${{ needs.prepare.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Checkout release tag | |
| run: git checkout "$TAG" | |
| - name: Normalize IMAGE_NS to lowercase | |
| run: echo "IMAGE_NS=$(echo '${{ env.IMAGE_NS }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.PR_AUTOMATION_TOKEN }} | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build & push ${{ matrix.name }} | |
| run: | | |
| docker buildx build --push \ | |
| -t "$REGISTRY/$IMAGE_NS/${{ matrix.name }}:${VERSION}" \ | |
| -t "$REGISTRY/$IMAGE_NS/${{ matrix.name }}:latest" \ | |
| -f "${{ matrix.dockerfile }}" . | |
| - name: Capture digest | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y jq | |
| ref="$REGISTRY/$IMAGE_NS/${{ matrix.name }}:${VERSION}" | |
| digest=$(docker buildx imagetools inspect "$ref" --format '{{json .Manifest.Digest}}' | jq -r . || true) | |
| jq -n --arg name "${{ matrix.name }}" --arg tag "$VERSION" --arg digest "$digest" '{($name): {tag: $tag, digest: $digest}}' > digest.json | |
| - name: Upload digest artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: image-digest-${{ matrix.name }} | |
| path: digest.json | |
| collect-digests: | |
| needs: [build-image] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download digest artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: image-digest-* | |
| merge-multiple: false | |
| - name: Merge digests | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y jq | |
| jq -s 'reduce .[] as $item ({}; . * $item)' image-digest-*/digest.json > image-digests.json | |
| - name: Upload merged digests | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: image-digests | |
| path: image-digests.json |