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 :
@@ -28,164 +29,106 @@ jobs:
2829 packages : write
2930 contents : read
3031 steps :
31- - name : Checkout repository
32+ - name : Checkout
3233 uses : actions/checkout@v4
3334
34- - name : Log into registry
35- if : env.PUSH == 'true'
36- uses : docker/login-action@v3.3.0
37- with :
38- registry : ghcr.io
39- username : ${{ github.actor }}
40- password : ${{ secrets.GITHUB_TOKEN }}
41-
42- - name : Extract Docker metadata
43- if : env.PUSH == 'true'
44- id : meta
45- uses : docker/metadata-action@v5.5.1
46- with :
47- images : ghcr.io/${{ github.repository }}
48- tags : |
49- type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}
50-
51- - name : Build and push Docker image
52- uses : docker/build-push-action@v6.7.0
53- with :
54- context : .
55- file : .docker/Dockerfile
56- build-args : ROS_DISTRO=${{ matrix.ROS_DISTRO }}
57- target : ${{ github.job }}
58- tags : ${{ steps.meta.outputs.tags }}
59- labels : ${{ steps.meta.outputs.labels }}
60- push : ${{ env.PUSH }}
61-
62- robot :
63- strategy :
64- fail-fast : false
65- matrix :
66- ROS_DISTRO : [jazzy]
67- runs-on : ubuntu-latest
68- permissions :
69- packages : write
70- contents : read
71- steps :
72- - name : Checkout repository
73- uses : actions/checkout@v4
74-
75- - name : Set up QEMU
76- uses : docker/setup-qemu-action@v3.2.0
35+ - # Add support for more platforms with QEMU (optional)
36+ # https://github.com/docker/setup-qemu-action
37+ name : Set up QEMU
38+ uses : docker/setup-qemu-action@v3
7739
7840 - name : Set up Docker Buildx
7941 uses : docker/setup-buildx-action@v3
8042
81- - name : Log into registry
82- if : env.PUSH == 'true'
43+ - if : env.PUSH == 'true'
44+ name : Log into registry
8345 uses : docker/login-action@v3.3.0
8446 with :
8547 registry : ghcr.io
8648 username : ${{ github.actor }}
8749 password : ${{ secrets.GITHUB_TOKEN }}
8850
89- - name : Extract Docker metadata
51+ # buildx bake, unfortunately, requires lower-cased repository names
52+ # This shell ... er, hack, creates a local variable containing
53+ # a down-cased version of $GITHUB_REPOSITORY
54+ #
55+ - id : lowercase-repo
56+ name : Repository to lowercase
57+ run : |
58+ echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT
59+
60+ # Set metadata for each stage-image separately
61+ - name : Set Docker metadata for "ci"
9062 if : env.PUSH == 'true'
91- id : meta
63+ id : meta-ci
9264 uses : docker/metadata-action@v5.5.1
9365 with :
9466 images : ghcr.io/${{ github.repository }}
67+ bake-target : docker-metadata-action-ci
9568 tags : |
96- type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}
97-
98- - name : Build and push Docker image
99- uses : docker/build-push-action@v6.7.0
100- with :
101- context : .
102- file : .docker/Dockerfile
103- build-args : ROS_DISTRO=${{ matrix.ROS_DISTRO }}
104- target : ${{ github.job }}
105- tags : ${{ steps.meta.outputs.tags }}
106- labels : ${{ steps.meta.outputs.labels }}
107- push : ${{ env.PUSH }}
108- platforms : linux/amd64
109- # platforms: linux/amd64,linux/arm64
110-
111- desktop :
112- strategy :
113- fail-fast : false
114- matrix :
115- ROS_DISTRO : [jazzy]
116- runs-on : ubuntu-latest
117- permissions :
118- packages : write
119- contents : read
120- steps :
121- - name : Checkout repository
122- uses : actions/checkout@v4
123-
124- - name : Log into registry
125- if : env.PUSH == 'true'
126- uses : docker/login-action@v3.3.0
127- with :
128- registry : ghcr.io
129- username : ${{ github.actor }}
130- password : ${{ secrets.GITHUB_TOKEN }}
69+ type=raw,value=${{ matrix.ROS_DISTRO }}-ci
13170
132- - name : Extract Docker metadata
71+ - name : Set Docker metadata for "robot"
13372 if : env.PUSH == 'true'
134- id : meta
73+ id : meta-robot
13574 uses : docker/metadata-action@v5.5.1
13675 with :
13776 images : ghcr.io/${{ github.repository }}
77+ bake-target : docker-metadata-action-robot
13878 tags : |
139- type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}
140-
141- - name : Build and push Docker image
142- uses : docker/build-push-action@v6.7.0
143- with :
144- context : .
145- file : .docker/Dockerfile
146- build-args : ROS_DISTRO=${{ matrix.ROS_DISTRO }}
147- target : ${{ github.job }}
148- tags : ${{ steps.meta.outputs.tags }}
149- labels : ${{ steps.meta.outputs.labels }}
150- push : ${{ env.PUSH }}
151-
152- desktop-nvidia :
153- strategy :
154- fail-fast : false
155- matrix :
156- ROS_DISTRO : [jazzy]
157- runs-on : ubuntu-latest
158- permissions :
159- packages : write
160- contents : read
161- steps :
162- - name : Checkout repository
163- uses : actions/checkout@v4
79+ type=raw,value=${{ matrix.ROS_DISTRO }}-robot
16480
165- - name : Log into registry
81+ - name : Set Docker metadata for "desktop"
16682 if : env.PUSH == 'true'
167- uses : docker/login-action@v3.3.0
83+ id : meta-desktop
84+ uses : docker/metadata-action@v5.5.1
16885 with :
169- registry : ghcr.io
170- username : ${{ github.actor }}
171- password : ${{ secrets.GITHUB_TOKEN }}
86+ images : ghcr.io/${{ github.repository }}
87+ bake-target : docker-metadata-action-desktop
88+ tags : |
89+ type=raw,value=${{ matrix.ROS_DISTRO }}-desktop
17290
173- - name : Extract Docker metadata
91+ - name : Set Docker metadata for "desktop-nvidia"
17492 if : env.PUSH == 'true'
175- id : meta
93+ id : meta-desktop-nvidia
17694 uses : docker/metadata-action@v5.5.1
17795 with :
17896 images : ghcr.io/${{ github.repository }}
97+ bake-target : docker-metadata-action-desktop-nvidia
17998 tags : |
180- type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}
181-
182- - name : Build and push Docker image
183- uses : docker/build-push-action@v6.7.0
99+ type=raw,value=${{ matrix.ROS_DISTRO }}-desktop-nvidia
100+
101+ - if : github.event_name == 'push'
102+ name : Build and push (non PR)
103+ uses : docker/bake-action@v5.5.0
104+ env :
105+ BLUE_ROS_DISTRO : ${{ matrix.ROS_DISTRO }}
106+ BLUE_GITHUB_REPO : ${{ steps.lowercase-repo.outputs.repository }}
184107 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 }}
108+ workdir : .docker
109+ files : |
110+ ./docker-bake.hcl
111+ ${{ steps.meta-ci.outputs.bake-file }}
112+ ${{ steps.meta-robot.outputs.bake-file }}
113+ ${{ steps.meta-desktop.outputs.bake-file }}
114+ ${{ steps.meta-desktop-nvidia.outputs.bake-file }}
191115 push : ${{ env.PUSH }}
116+ set : |
117+ *.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }}
118+ *.cache-to=type=registry,mode=max,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }}
119+
120+ # Pull request builds are not cached; and only built for AMD64
121+ - if : github.event_name == 'pull_request'
122+ name : Build and push (PR)
123+ uses : docker/bake-action@v5.5.0
124+ env :
125+ BLUE_ROS_DISTRO : ${{ matrix.ROS_DISTRO }}
126+ BLUE_GITHUB_REPO : ${{ steps.lowercase-repo.outputs.repository }}
127+ with :
128+ workdir : .docker
129+ files : |
130+ ./docker-bake.hcl
131+ set : |
132+ *.platform=linux/amd64
133+ *.cache-from=type=registry,ref=ghcr.io/${{ github.repository }}:cache-${{ matrix.ROS_DISTRO }}
134+ *.cache-to=
0 commit comments