Build and Push Docker Images #4
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 Images | |
| on: | |
| push: | |
| branches: [ "main", "fix/mcp-docstrings" ] | |
| tags: [ 'v*.*.*' ] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to use for the images (defaults to latest)' | |
| required: false | |
| default: 'latest' | |
| env: | |
| REGISTRY: ghcr.io | |
| # Use github.repository_owner to dynamically handle the namespace (e.g., mpnikhil) | |
| IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log into registry ${{ env.REGISTRY }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Green Agent | |
| id: meta-green | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_PREFIX }}/webshop-plus-green | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }} | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=sha | |
| - name: Build and push Green Agent | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: green_agent/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta-green.outputs.tags }} | |
| labels: ${{ steps.meta-green.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Extract metadata (tags, labels) for Purple Agent | |
| id: meta-purple | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_PREFIX }}/webshop-plus-purple | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }} | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=sha | |
| - name: Build and push Purple Agent | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: purple_agent/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta-purple.outputs.tags }} | |
| labels: ${{ steps.meta-purple.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |