|
| 1 | +name: Build and Push Sandbox Images |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - "docker/Dockerfile.base" |
| 9 | + - "docker/Dockerfile.agents" |
| 10 | + - "exercises/**" |
| 11 | + - ".github/workflows/build-images.yml" |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + reason: |
| 15 | + description: "Reason for manual rebuild" |
| 16 | + required: false |
| 17 | + default: "Manual trigger" |
| 18 | + |
| 19 | +env: |
| 20 | + REGISTRY: ghcr.io |
| 21 | + BASE_IMAGE: mmerrell/temporal-python-sandbox |
| 22 | + AGENTS_IMAGE: mmerrell/temporal-python-agents-sandbox |
| 23 | + |
| 24 | +jobs: |
| 25 | + build-base: |
| 26 | + name: Build temporal-python-sandbox (base) |
| 27 | + runs-on: ubuntu-latest |
| 28 | + permissions: |
| 29 | + contents: read |
| 30 | + packages: write |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout repository |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Log in to GitHub Container Registry |
| 37 | + uses: docker/login-action@v3 |
| 38 | + with: |
| 39 | + registry: ${{ env.REGISTRY }} |
| 40 | + username: ${{ github.actor }} |
| 41 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + |
| 43 | + - name: Extract Docker metadata |
| 44 | + id: meta |
| 45 | + uses: docker/metadata-action@v5 |
| 46 | + with: |
| 47 | + images: ${{ env.REGISTRY }}/${{ env.BASE_IMAGE }} |
| 48 | + tags: | |
| 49 | + type=sha,prefix=sha-,format=short |
| 50 | + type=raw,value=latest,enable={{is_default_branch}} |
| 51 | +
|
| 52 | + - name: Set up Docker Buildx |
| 53 | + uses: docker/setup-buildx-action@v3 |
| 54 | + |
| 55 | + - name: Build and push base image |
| 56 | + uses: docker/build-push-action@v5 |
| 57 | + with: |
| 58 | + context: . |
| 59 | + file: docker/Dockerfile.base |
| 60 | + platforms: linux/amd64 |
| 61 | + push: true |
| 62 | + tags: ${{ steps.meta.outputs.tags }} |
| 63 | + labels: ${{ steps.meta.outputs.labels }} |
| 64 | + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.BASE_IMAGE }}:buildcache |
| 65 | + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.BASE_IMAGE }}:buildcache,mode=max |
| 66 | + |
| 67 | + build-agents: |
| 68 | + name: Build temporal-python-agents-sandbox |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: build-base |
| 71 | + permissions: |
| 72 | + contents: read |
| 73 | + packages: write |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: Checkout repository |
| 77 | + uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Log in to GitHub Container Registry |
| 80 | + uses: docker/login-action@v3 |
| 81 | + with: |
| 82 | + registry: ${{ env.REGISTRY }} |
| 83 | + username: ${{ github.actor }} |
| 84 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + |
| 86 | + - name: Extract Docker metadata |
| 87 | + id: meta |
| 88 | + uses: docker/metadata-action@v5 |
| 89 | + with: |
| 90 | + images: ${{ env.REGISTRY }}/${{ env.AGENTS_IMAGE }} |
| 91 | + tags: | |
| 92 | + type=sha,prefix=sha-,format=short |
| 93 | + type=raw,value=latest,enable={{is_default_branch}} |
| 94 | +
|
| 95 | + - name: Set up Docker Buildx |
| 96 | + uses: docker/setup-buildx-action@v3 |
| 97 | + |
| 98 | + - name: Build and push agents image |
| 99 | + uses: docker/build-push-action@v5 |
| 100 | + with: |
| 101 | + context: . |
| 102 | + file: docker/Dockerfile.agents |
| 103 | + platforms: linux/amd64 |
| 104 | + push: true |
| 105 | + tags: ${{ steps.meta.outputs.tags }} |
| 106 | + labels: ${{ steps.meta.outputs.labels }} |
| 107 | + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.AGENTS_IMAGE }}:buildcache |
| 108 | + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.AGENTS_IMAGE }}:buildcache,mode=max |
0 commit comments