Rename bun_canvas.dockerfile to bun_canvas.Dockerfile #4
This file contains 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 Publish Docker Images | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get list of Dockerfiles | |
id: dockerfiles | |
run: | | |
echo "files=$(find ./images -type f -name "*.Dockerfile" | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker images | |
run: | | |
for dockerfile in $(echo '${{ steps.dockerfiles.outputs.files }}' | jq -r '.[]'); do | |
name=$(basename "$dockerfile" .Dockerfile) | |
# Build and push with both latest and SHA tags | |
docker buildx build \ | |
--file "$dockerfile" \ | |
--push \ | |
--tag "ghcr.io/buape/dockyard-${name}:latest" \ | |
--tag "ghcr.io/buape/dockyard-${name}:${GITHUB_SHA}" \ | |
--cache-from "type=gha" \ | |
--cache-to "type=gha,mode=max" \ | |
. | |
echo "Built and pushed ghcr.io/buape/dockyard-${name}" | |
done |