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 - jazzy
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 :
@@ -122,22 +142,19 @@ jobs:
122142 uses : actions/checkout@v4
123143
124144 - name : Log into registry
145+ =======
146+ - name : Set Docker metadata for "robot"
147+ >>>>>>> a8681d0 (Add Docker BuildX config (#266))
125148 if : env.PUSH == 'true'
126- 127- with :
128- registry : ghcr.io
129- username : ${{ github.actor }}
130- password : ${{ secrets.GITHUB_TOKEN }}
131-
132- - name : Extract Docker metadata
133- if : env.PUSH == 'true'
134- id : meta
149+ id : meta-robot
135150136151 with :
137152 images : ghcr.io/${{ github.repository }}
153+ bake-target : docker-metadata-action-robot
138154 tags : |
139- type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}
155+ type=raw,value=${{ matrix.ROS_DISTRO }}-robot
140156
157+ <<<<<<< HEAD
141158 - name : Build and push Docker image
142159143160 with :
@@ -163,29 +180,59 @@ jobs:
163180 uses : actions/checkout@v4
164181
165182 - name : Log into registry
183+ =======
184+ - name : Set Docker metadata for "desktop"
185+ >>>>>>> a8681d0 (Add Docker BuildX config (#266))
166186 if : env.PUSH == 'true'
167- 187+ id : meta-desktop
188+ 168189 with :
169- registry : ghcr.io
170- username : ${{ github.actor }}
171- password : ${{ secrets.GITHUB_TOKEN }}
190+ images : ghcr.io/${{ github.repository }}
191+ bake-target : docker-metadata-action-desktop
192+ tags : |
193+ type=raw,value=${{ matrix.ROS_DISTRO }}-desktop
172194
173- - name : Extract Docker metadata
195+ - name : Set Docker metadata for "desktop-nvidia"
174196 if : env.PUSH == 'true'
175- id : meta
197+ id : meta-desktop-nvidia
176198177199 with :
178200 images : ghcr.io/${{ github.repository }}
201+ bake-target : docker-metadata-action-desktop-nvidia
179202 tags : |
180- type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}
181-
182- - name : Build and push Docker image
183- 203+ type=raw,value=${{ matrix.ROS_DISTRO }}-desktop-nvidia
204+
205+ - if : github.event_name == 'push'
206+ name : Build and push (non PR)
207+ 208+ env :
209+ BLUE_ROS_DISTRO : ${{ matrix.ROS_DISTRO }}
210+ BLUE_GITHUB_REPO : ${{ steps.lowercase-repo.outputs.repository }}
184211 with :
185- context : .
186- file : .docker/Dockerfile
187- build-args : ROS_DISTRO=${{ matrix.ROS_DISTRO }}
188- target : ${{ github.job }}
189- tags : ${{ steps.meta.outputs.tags }}
190- labels : ${{ steps.meta.outputs.labels }}
212+ workdir : .docker
213+ files : |
214+ ./docker-bake.hcl
215+ ${{ steps.meta-ci.outputs.bake-file }}
216+ ${{ steps.meta-robot.outputs.bake-file }}
217+ ${{ steps.meta-desktop.outputs.bake-file }}
218+ ${{ steps.meta-desktop-nvidia.outputs.bake-file }}
191219 push : ${{ env.PUSH }}
220+ set : |
221+ *.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }}
222+ *.cache-to=type=registry,mode=max,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }}
223+
224+ # Pull request builds are not cached; and only built for AMD64
225+ - if : github.event_name == 'pull_request'
226+ name : Build and push (PR)
227+ 228+ env :
229+ BLUE_ROS_DISTRO : ${{ matrix.ROS_DISTRO }}
230+ BLUE_GITHUB_REPO : ${{ steps.lowercase-repo.outputs.repository }}
231+ with :
232+ workdir : .docker
233+ files : |
234+ ./docker-bake.hcl
235+ set : |
236+ *.platform=linux/amd64
237+ *.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }}
238+ *.cache-to=
0 commit comments