diff --git a/.github/actions/docker-build-push/action.yml b/.github/actions/docker-build-push/action.yml new file mode 100644 index 0000000000..c9e4ddf301 --- /dev/null +++ b/.github/actions/docker-build-push/action.yml @@ -0,0 +1,32 @@ +name: Docker build and push +description: Common setup steps used by our workflows +inputs: + image: + description: Docker image to publish + required: true + stage: + description: Dockerfile build stage + required: true +runs: + using: composite + steps: + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.6.0 + with: + context: git + images: ${{ inputs.image }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=match,pattern=@(.*),group=1 + type=match,pattern=@.*-(next),group=1 + type=ref,event=branch + type=sha + - name: Build and push Docker image + uses: docker/build-push-action@v4.2.1 + with: + context: . + push: true + target: ${{ inputs.stage }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f0130f2d8c..d50b372d6f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,23 +29,19 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4.6.0 + # Build and push each stage of the Dockerfile in order + - name: "Build and push: mud" + uses: ./.github/actions/docker-build-push with: - context: git - images: ${{ matrix.image }} - tags: | - type=raw,value=latest,enable={{is_default_branch}} - type=match,pattern=@(.*),group=1 - type=match,pattern=@.*-(next),group=1 - type=ref,event=branch - type=sha - - name: Build and push Docker image - uses: docker/build-push-action@v4.2.1 + image: ghcr.io/latticexyz/mud + stage: mud + - name: "Build and push: store-indexer" + uses: ./.github/actions/docker-build-push with: - context: . - push: true - target: ${{ matrix.target }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + image: ghcr.io/latticexyz/store-indexer + stage: store-indexer + - name: "Build and push: faucet" + uses: ./.github/actions/docker-build-push + with: + image: ghcr.io/latticexyz/faucet + stage: faucet