77 type : [published]
88
99env :
10- TEST_TAG : dessimozlab/fastoma:test
10+ REGISTRY_IMAGE : dessimozlab/fastoma
1111
1212jobs :
1313
1414 build :
1515
16- runs-on : ubuntu-latest
16+ strategy :
17+ fail-fast : false
18+ matrix :
19+ include :
20+ - platform : linux/amd64
21+ runner : ubuntu-latest
22+ - platform : linux/arm64
23+ runner : ubuntu-24.04-arm
24+
25+ runs-on : ${{ matrix.runner }}
1726
1827 steps :
28+ - name : Prepare
29+ run : |
30+ platform=${{ matrix.platform }}
31+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
32+
1933 - name : Checkout
20- uses : actions/checkout@v6.0.1
34+ uses : actions/checkout@v6
2135 with :
2236 submodules : recursive
2337
2640 uses : docker/metadata-action@v5
2741 with :
2842 # list of Docker images to use as base name for tags
29- images : |
30- dessimozlab/fastoma
43+ images : ${{ env.REGISTRY_IMAGE }}
3144 # generate Docker tags based on the following events/attributes
3245 tags : |
3346 type=schedule
@@ -47,40 +60,80 @@ jobs:
4760 - name : Set up Docker Buildx
4861 uses : docker/setup-buildx-action@v3
4962
50- - name : Build and export to docker for testing
51- uses : docker/build-push-action@v6
52- with :
53- context : .
54- load : true
55- tags : ${{ env.TEST_TAG }}
56-
57- # - name: Test
58- # run: |
59- # docker run --rm -i -v $PWD/tests:/input -v $PWD/tests/:/reads -v $PWD/output:/out -v $PWD/run:/run ${{ env.TEST_TAG }} --tree --standalone_path /input/marker_genes --dna_reference /input/cds-marker_genes.fasta.gz --reads /reads/sample_1.fastq --output_path /out
60- # if [ ! -f output/tree_sample_1.nwk ] ; then exit 1; fi
61-
6263 - name : Login to DockerHub
6364 uses : docker/login-action@v3
6465 with :
6566 username : ${{ secrets.DOCKER_HUB_USERNAME }}
6667 password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
6768
68- - name : Set platforms
69- id : set_platforms
70- run : |
71- echo "github ref: ${GITHUB_REF}"
72- if [[ "${GITHUB_REF##*/}" == "main" || "${GITHUB_REF##*/}" == "dev" || "${GITHUB_REF}" == "refs/tags/"* ]]; then
73- echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
74- else
75- echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
76- fi
77-
78- - name : Build and push
69+ - name : Build and push by digest only
70+ id : build
7971 uses : docker/build-push-action@v6
8072 with :
8173 context : .
82- platforms : ${{ steps.set_platforms.outputs.platforms }}
83- push : true
84- # ${{ github.event_name != 'push' && github.event_name != 'pull_request' }}
85- tags : ${{ steps.meta.outputs.tags }}
74+ platforms : ${{ matrix.platform }}
75+ tags : ${{ env.REGISTRY_IMAGE }}
8676 labels : ${{ steps.meta.outputs.labels }}
77+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
78+
79+ - name : Export digest
80+ run : |
81+ mkdir -p ${{ runner.temp }}/digests
82+ digest="${{ steps.build.outputs.digest }}"
83+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
84+
85+ - name : Upload digest
86+ uses : actions/upload-artifact@v4
87+ with :
88+ name : digests-${{ env.PLATFORM_PAIR }}
89+ path : ${{ runner.temp }}/digests/*
90+ if-no-files-found : error
91+ retention-days : 1
92+
93+ merge :
94+ runs-on : ubuntu-latest
95+ needs :
96+ - build
97+ steps :
98+ - name : Download digests
99+ uses : actions/download-artifact@v4
100+ with :
101+ path : ${{ runner.temp }}/digests
102+ pattern : digests-*
103+ merge-multiple : true
104+
105+ - name : Login to Docker Hub
106+ uses : docker/login-action@v3
107+ with :
108+ username : ${{ vars.DOCKERHUB_USERNAME }}
109+ password : ${{ secrets.DOCKERHUB_TOKEN }}
110+
111+ - name : Set up Docker Buildx
112+ uses : docker/setup-buildx-action@v3
113+
114+ - name : Docker meta
115+ id : meta
116+ uses : docker/metadata-action@v5
117+ with :
118+ images : ${{ env.REGISTRY_IMAGE }}
119+ tags : |
120+ type=schedule
121+ type=ref,event=branch
122+ type=ref,event=pr
123+ type=semver,pattern={{version}}
124+ type=semver,pattern={{major}}.{{minor}}
125+ type=semver,pattern={{major}}
126+ type=sha
127+ labels : |
128+ org.opencontainers.image.source=${{ github.repository }}
129+ org.opencontainers.image.revision=${{ github.sha }}
130+
131+ - name : Create manifest list and push
132+ working-directory : ${{ runner.temp }}/digests
133+ run : |
134+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
135+ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
136+
137+ - name : Inspect image
138+ run : |
139+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
0 commit comments