File tree Expand file tree Collapse file tree 3 files changed +52
-7
lines changed
Expand file tree Collapse file tree 3 files changed +52
-7
lines changed Original file line number Diff line number Diff line change 11# Action that wraps together all the necessary actions to build an image and publish it.
22# It does not include login actions.
33# This is a convenience, so that we know that everything related to the build lies in this file,
4- # and if it gets updated we can automatically run our `test-docker-build` from `build-test.yml.`
4+ # and if it gets updated we can automatically run our `test-docker-build` from `build-test.yml.`,
5+ # so there is no confusion about which is the job that was updated, if there are many in the same workflow file.
56
67name : " Docker Build"
78description : " Builds Docker images with optional caching and multi-platform support"
89
910inputs :
10- push-image :
11+ push :
1112 description : " Whether to push the built image"
1213 required : false
1314 default : " false"
15+ load :
16+ description : " Whether to load the built image"
17+ required : false
18+ default : " false"
1419 platforms :
1520 description : " Target platforms for the build"
1621 required : false
5560 with :
5661 context : ${{ inputs.context }}
5762 file : ${{ inputs.dockerfile }}
58- push : ${{ inputs[' push-image'] }}
63+ push : ${{ inputs. push }}
5964 platforms : ${{ inputs.platforms }}
6065 tags : ${{ steps.meta.outputs.tags }}
6166 labels : ${{ steps.meta.outputs.labels }}
6267 cache-from : ${{ inputs['cache-from'] }}
6368 cache-to : ${{ inputs['cache-to'] }}
69+ load : ${{ inputs.load }}
Original file line number Diff line number Diff line change 7171 docker : ${{ steps.docker-changes.outputs.docker }}
7272 workflow : ${{ steps.docker-changes.outputs.workflow }}
7373
74- test-docker-build :
74+ test-docker-build-arm64 :
7575 needs : [should-test-docker-build]
7676 name : Test Docker build
7777 runs-on : ubuntu-latest
9696 context : .
9797 file : ./Dockerfile
9898 push : false
99- platforms : linux/amd64,linux/arm64
99+ load : true
100+ platforms : linux/arm64
100101 cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache
101-
102+ iamge-name : build-arm64
103+
104+ - name : Test
105+ run : |
106+ docker run --rm build-arm64 --version
107+
108+ test-docker-build-amd64 :
109+ needs : [should-test-docker-build]
110+ name : Test Docker build
111+ runs-on : ubuntu-latest
112+ if : (needs.should-test-docker-build.outputs.workflow == 'true' || needs.should-test-docker-build.outputs.docker == 'true') && !startsWith(github.event.head_commit.message, 'bump:')
113+ permissions :
114+ contents : read
115+ packages : read
116+ steps :
117+ - name : Check out the repo
118+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
119+
120+ - name : Log in to GitHub Container Registry
121+ uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
122+ with :
123+ registry : ghcr.io
124+ username : ${{ github.actor }}
125+ password : ${{ secrets.GITHUB_TOKEN }}
126+
127+ - name : Build image
128+ uses : ./.github/actions/docker-build
129+ with :
130+ context : .
131+ file : ./Dockerfile
132+ push : false
133+ load : true
134+ platforms : linux/amd64
135+ cache-from : type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache
136+ iamge-name : build-amd64
137+
138+ - name : Test
139+ run : |
140+ docker run --rm build-amd64 --version
Original file line number Diff line number Diff line change 5353 - name : Build and push Docker image
5454 uses : ./.github/actions/docker-build
5555 with :
56- push-image : " true"
56+ push : " true"
5757 platforms : linux/amd64,linux/arm64
5858 dockerfile : ./Dockerfile
5959 context : .
You can’t perform that action at this time.
0 commit comments