1- on :
2- workflow_dispatch :
3-
1+ name : Build and Push Docker Image
42
5- env :
6- REGISTRY : ghcr.io
7- IMAGE_NAME : bevy-mod-scripting
3+ on :
4+ push :
5+ branches : [ main ]
6+ workflow_dispatch : # Allow manual triggering
87
98jobs :
10- build-runner-image :
9+ docker :
10+ runs-on : ubuntu-latest
1111 permissions :
1212 contents : read
1313 packages : write
14- runs-on : ubuntu-latest
15- name : Build multi-platform Docker image
16- outputs :
17- image : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }}
14+
1815 steps :
19- - uses : actions/checkout@v4
20- - uses : docker/setup-qemu-action@v3
21- - uses : docker/setup-buildx-action@v3
22- - name : Docker meta
23- id : meta
24- uses : docker/metadata-action@v5
16+ - name : Checkout repository
17+ uses : actions/checkout@v4
18+ with :
19+ submodules : ' recursive'
20+
21+ - name : Set up Docker Buildx
22+ uses : docker/setup-buildx-action@v3
23+
24+ - name : Set up QEMU
25+ uses : docker/setup-qemu-action@v3
2526 with :
26- images : |
27- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
28- - name : Login to GitHub Container Registry
27+ platforms : ' arm64,amd64'
28+
29+ - name : Login to DockerHub
30+ if : github.event_name != 'pull_request'
2931 uses : docker/login-action@v3
3032 with :
31- registry : ghcr.io
32- username : ${{ github.actor }}
33- password : ${{ secrets.GITHUB_TOKEN }}
34- - uses : docker/build-push-action@v5
33+ username : ${{ secrets.DOCKERHUB_USER }}
34+ password : ${{ secrets.DOCKERHUB_TOKEN }}
35+
36+ - name : Extract metadata for Docker
37+ id : meta
38+ uses : docker/metadata-action@v5
39+ with :
40+ images : makspll/bevy_mod_scripting
41+ flavor : |
42+ prefix=xtask-
43+ tags : |
44+ type=ref,event=branch
45+ type=ref,event=pr
46+ type=semver,pattern={{version}}
47+ type=semver,pattern={{major}}.{{minor}}
48+ type=sha,format=short
49+ type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
50+
51+ - name : Build and push Docker image
52+ uses : docker/build-push-action@v5
3553 with :
3654 context : .
37- file : ./crates/xtask/ Dockerfile
55+ file : ./Dockerfile
3856 platforms : linux/amd64,linux/arm64
39- cache-from : type=gha
40- cache-to : type=gha,mode=max
57+ push : true
4158 tags : ${{ steps.meta.outputs.tags }}
4259 labels : ${{ steps.meta.outputs.labels }}
60+ cache-from : type=gha
61+ cache-to : type=gha,mode=max
0 commit comments