Skip to content

Commit

Permalink
ci: refactor docker build (#2783)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored May 1, 2024
1 parent 2b0f8bb commit b6c60a0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 18 deletions.
32 changes: 32 additions & 0 deletions .github/actions/docker-build-push/action.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
with:
context: .
push: true
target: ${{ inputs.stage }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
32 changes: 14 additions & 18 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
# 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/[email protected]
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

0 comments on commit b6c60a0

Please sign in to comment.