11name : Docker
22
33on :
4- schedule :
5- - cron : " 0 17 * * 6"
4+ # Disable schedule for preliminary testing
5+ # schedule:
6+ # - cron: "0 17 * * 6"
67 push :
78 branches :
89 - humble
1819 PUSH : ${{ (github.event_name != 'pull_request') && (github.repository == 'Robotic-Decision-Making-Lab/blue') }}
1920
2021jobs :
21- ci :
22+ docker_build :
2223 strategy :
2324 fail-fast : false
2425 matrix :
2829 packages : write
2930 contents : read
3031 steps :
31- - name : Checkout repository
32+ - name : Checkout
3233 uses : actions/checkout@v4
3334
35+ <<<<<<< HEAD
3436 - name : Log into registry
3537 if : env.PUSH == 'true'
3638@@ -74,27 +76,45 @@ jobs:
7476
7577 - name : Set up QEMU
767879+ =======
80+ - # Add support for more platforms with QEMU (optional)
81+ # https://github.com/docker/setup-qemu-action
82+ name : Set up QEMU
83+ uses : docker/setup-qemu-action@v3
84+ >>>>>>> a8681d0 (Add Docker BuildX config (#266))
7785
7886 - name : Set up Docker Buildx
7987 uses : docker/setup-buildx-action@v3
8088
81- - name : Log into registry
82- if : env.PUSH == 'true'
89+ - if : env.PUSH == 'true'
90+ name : Log into registry
83918492 with :
8593 registry : ghcr.io
8694 username : ${{ github.actor }}
8795 password : ${{ secrets.GITHUB_TOKEN }}
8896
89- - name : Extract Docker metadata
97+ # buildx bake, unfortunately, requires lower-cased repository names
98+ # This shell ... er, hack, creates a local variable containing
99+ # a down-cased version of $GITHUB_REPOSITORY
100+ #
101+ - id : lowercase-repo
102+ name : Repository to lowercase
103+ run : |
104+ echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT
105+
106+ # Set metadata for each stage-image separately
107+ - name : Set Docker metadata for "ci"
90108 if : env.PUSH == 'true'
91- id : meta
109+ id : meta-ci
9211093111 with :
94112 images : ghcr.io/${{ github.repository }}
113+ bake-target : docker-metadata-action-ci
95114 tags : |
96- type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}
115+ type=raw,value=${{ matrix.ROS_DISTRO }}-ci
97116
117+ <<<<<<< HEAD
98118 - name : Build and push Docker image
99119100120 with :
@@ -121,22 +141,19 @@ jobs:
121141 uses : actions/checkout@v4
122142
123143 - name : Log into registry
144+ =======
145+ - name : Set Docker metadata for "robot"
146+ >>>>>>> a8681d0 (Add Docker BuildX config (#266))
124147 if : env.PUSH == 'true'
125- 126- with :
127- registry : ghcr.io
128- username : ${{ github.actor }}
129- password : ${{ secrets.GITHUB_TOKEN }}
130-
131- - name : Extract Docker metadata
132- if : env.PUSH == 'true'
133- id : meta
148+ id : meta-robot
134149135150 with :
136151 images : ghcr.io/${{ github.repository }}
152+ bake-target : docker-metadata-action-robot
137153 tags : |
138- type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}
154+ type=raw,value=${{ matrix.ROS_DISTRO }}-robot
139155
156+ <<<<<<< HEAD
140157 - name : Build and push Docker image
141158142159 with :
@@ -162,29 +179,59 @@ jobs:
162179 uses : actions/checkout@v4
163180
164181 - name : Log into registry
182+ =======
183+ - name : Set Docker metadata for "desktop"
184+ >>>>>>> a8681d0 (Add Docker BuildX config (#266))
165185 if : env.PUSH == 'true'
166- 186+ id : meta-desktop
187+ 167188 with :
168- registry : ghcr.io
169- username : ${{ github.actor }}
170- password : ${{ secrets.GITHUB_TOKEN }}
189+ images : ghcr.io/${{ github.repository }}
190+ bake-target : docker-metadata-action-desktop
191+ tags : |
192+ type=raw,value=${{ matrix.ROS_DISTRO }}-desktop
171193
172- - name : Extract Docker metadata
194+ - name : Set Docker metadata for "desktop-nvidia"
173195 if : env.PUSH == 'true'
174- id : meta
196+ id : meta-desktop-nvidia
175197176198 with :
177199 images : ghcr.io/${{ github.repository }}
200+ bake-target : docker-metadata-action-desktop-nvidia
178201 tags : |
179- type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}
180-
181- - name : Build and push Docker image
182- 202+ type=raw,value=${{ matrix.ROS_DISTRO }}-desktop-nvidia
203+
204+ - if : github.event_name == 'push'
205+ name : Build and push (non PR)
206+ 207+ env :
208+ BLUE_ROS_DISTRO : ${{ matrix.ROS_DISTRO }}
209+ BLUE_GITHUB_REPO : ${{ steps.lowercase-repo.outputs.repository }}
183210 with :
184- context : .
185- file : .docker/Dockerfile
186- build-args : ROS_DISTRO=${{ matrix.ROS_DISTRO }}
187- target : ${{ github.job }}
188- tags : ${{ steps.meta.outputs.tags }}
189- labels : ${{ steps.meta.outputs.labels }}
211+ workdir : .docker
212+ files : |
213+ ./docker-bake.hcl
214+ ${{ steps.meta-ci.outputs.bake-file }}
215+ ${{ steps.meta-robot.outputs.bake-file }}
216+ ${{ steps.meta-desktop.outputs.bake-file }}
217+ ${{ steps.meta-desktop-nvidia.outputs.bake-file }}
190218 push : ${{ env.PUSH }}
219+ set : |
220+ *.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }}
221+ *.cache-to=type=registry,mode=max,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }}
222+
223+ # Pull request builds are not cached; and only built for AMD64
224+ - if : github.event_name == 'pull_request'
225+ name : Build and push (PR)
226+ 227+ env :
228+ BLUE_ROS_DISTRO : ${{ matrix.ROS_DISTRO }}
229+ BLUE_GITHUB_REPO : ${{ steps.lowercase-repo.outputs.repository }}
230+ with :
231+ workdir : .docker
232+ files : |
233+ ./docker-bake.hcl
234+ set : |
235+ *.platform=linux/amd64
236+ *.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }}
237+ *.cache-to=
0 commit comments