|
| 1 | +name: Build and Push Docker Images |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main", "fix/mcp-docstrings" ] |
| 6 | + tags: [ 'v*.*.*' ] |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Tag to use for the images (defaults to latest)' |
| 11 | + required: false |
| 12 | + default: 'latest' |
| 13 | + |
| 14 | +env: |
| 15 | + REGISTRY: ghcr.io |
| 16 | + # Use github.repository_owner to dynamically handle the namespace (e.g., mpnikhil) |
| 17 | + IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + packages: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Set up Docker Buildx |
| 31 | + uses: docker/setup-buildx-action@v3 |
| 32 | + |
| 33 | + - name: Log into registry ${{ env.REGISTRY }} |
| 34 | + uses: docker/login-action@v3 |
| 35 | + with: |
| 36 | + registry: ${{ env.REGISTRY }} |
| 37 | + username: ${{ github.actor }} |
| 38 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + - name: Extract metadata (tags, labels) for Green Agent |
| 41 | + id: meta-green |
| 42 | + uses: docker/metadata-action@v5 |
| 43 | + with: |
| 44 | + images: ${{ env.IMAGE_PREFIX }}/webshop-plus-green |
| 45 | + tags: | |
| 46 | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} |
| 47 | + type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }} |
| 48 | + type=ref,event=branch |
| 49 | + type=ref,event=tag |
| 50 | + type=sha |
| 51 | +
|
| 52 | + - name: Build and push Green Agent |
| 53 | + uses: docker/build-push-action@v5 |
| 54 | + with: |
| 55 | + context: . |
| 56 | + file: green_agent/Dockerfile |
| 57 | + push: true |
| 58 | + tags: ${{ steps.meta-green.outputs.tags }} |
| 59 | + labels: ${{ steps.meta-green.outputs.labels }} |
| 60 | + cache-from: type=gha |
| 61 | + cache-to: type=gha,mode=max |
| 62 | + |
| 63 | + - name: Extract metadata (tags, labels) for Purple Agent |
| 64 | + id: meta-purple |
| 65 | + uses: docker/metadata-action@v5 |
| 66 | + with: |
| 67 | + images: ${{ env.IMAGE_PREFIX }}/webshop-plus-purple |
| 68 | + tags: | |
| 69 | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} |
| 70 | + type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }} |
| 71 | + type=ref,event=branch |
| 72 | + type=ref,event=tag |
| 73 | + type=sha |
| 74 | +
|
| 75 | + - name: Build and push Purple Agent |
| 76 | + uses: docker/build-push-action@v5 |
| 77 | + with: |
| 78 | + context: . |
| 79 | + file: purple_agent/Dockerfile |
| 80 | + push: true |
| 81 | + tags: ${{ steps.meta-purple.outputs.tags }} |
| 82 | + labels: ${{ steps.meta-purple.outputs.labels }} |
| 83 | + cache-from: type=gha |
| 84 | + cache-to: type=gha,mode=max |
0 commit comments