88
99env :
1010 REGISTRY : ghcr.io
11- IMAGE_NAME : ${{ github.repository }}
11+ IMAGE_BASE : ${{ github.repository }}
1212
1313jobs :
1414 build :
1515 runs-on : ubuntu-latest
1616 permissions :
1717 contents : read
1818 packages : write
19+
20+ strategy :
21+ matrix :
22+ include :
23+ - image_suffix : " "
24+ dockerfile : Dockerfile.buildkit
25+ description : " Kimia (BuildKit-based)"
26+ - image_suffix : " -bud"
27+ dockerfile : Dockerfile.buildah
28+ description : " Kimia-Bud (Buildah-based)"
1929
2030 steps :
2131 - name : Checkout code
@@ -35,49 +45,55 @@ jobs:
3545 username : ${{ github.actor }}
3646 password : ${{ secrets.GITHUB_TOKEN }}
3747
38- - name : Extract metadata
48+ - name : Extract metadata for ${{ matrix.description }}
3949 id : meta
4050 uses : docker/metadata-action@v5
4151 with :
42- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}${{ matrix.image_suffix }}
4353 tags : |
4454 type=ref,event=branch
4555 type=ref,event=pr
46- # Use a fixed prefix for SHA-based tags to avoid producing an
47- # invalid tag when the branch template is empty (which can
48- # generate a leading '-' like ":-df2dc06"). This produces
49- # tags like 'sha-df2dc06' which are valid.
5056 type=sha,prefix=sha-
57+ type=raw,value=latest,enable={{is_default_branch}}
5158
52- - name : Build multi-arch image (with cache & push )
59+ - name : Build and push ${{ matrix.description }} (main/init branch )
5360 if : github.event_name != 'pull_request'
5461 uses : docker/build-push-action@v5
5562 with :
5663 context : .
57- file : ./Dockerfile
64+ file : ./${{ matrix.dockerfile }}
5865 platforms : linux/amd64,linux/arm64
5966 push : true
6067 tags : ${{ steps.meta.outputs.tags }}
6168 labels : ${{ steps.meta.outputs.labels }}
62- cache-from : type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
63- cache-to : type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
69+ cache-from : type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}${{ matrix.image_suffix }}:buildcache
70+ cache-to : type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}${{ matrix.image_suffix }}:buildcache,mode=max
6471
65- - name : Build multi-arch image (PR — no registry cache )
72+ - name : Build ${{ matrix.description }} (PR - no push )
6673 if : github.event_name == 'pull_request'
6774 uses : docker/build-push-action@v5
6875 with :
6976 context : .
70- file : ./Dockerfile
77+ file : ./${{ matrix.dockerfile }}
7178 platforms : linux/amd64,linux/arm64
72- # Do not push on PRs and avoid accessing GHCR for cache (avoids 403)
7379 push : false
7480 tags : ${{ steps.meta.outputs.tags }}
7581 labels : ${{ steps.meta.outputs.labels }}
7682
83+ test :
84+ runs-on : ubuntu-latest
85+ needs : build
86+ if : always()
87+
88+ steps :
89+ - name : Checkout code
90+ uses : actions/checkout@v4
91+
7792 - name : Run tests
7893 run : |
7994 if [ -f tests/master.sh ]; then
8095 chmod +x tests/master.sh
81- # Add test commands here
82- fi
83-
96+ ./tests/master.sh
97+ else
98+ echo "No tests found, skipping..."
99+ fi
0 commit comments