-
Notifications
You must be signed in to change notification settings - Fork 15
133 lines (120 loc) · 4.33 KB
/
docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Docker
on:
schedule:
- cron: "0 17 * * 6"
push:
branches:
- humble
pull_request:
paths:
- .docker/**
- .github/workflows/docker.yaml
- blue.repos
- requirements-build.txt
workflow_dispatch:
env:
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'Robotic-Decision-Making-Lab/blue') }}
jobs:
docker_build:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- # Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- if: env.PUSH == 'true'
name: Log into registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# buildx bake, unfortunately, requires lower-cased repository names
# This shell ... er, hack, creates a local variable containing
# a down-cased version of $GITHUB_REPOSITORY
#
- id: lowercase-repo
name: Repository to lowercase
run: |
echo "repository=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT
# Set metadata for each stage-image separately
- name: Set Docker metadata for "ci"
if: env.PUSH == 'true'
id: meta-ci
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
bake-target: docker-metadata-action-ci
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-ci
- name: Set Docker metadata for "robot"
if: env.PUSH == 'true'
id: meta-robot
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
bake-target: docker-metadata-action-robot
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-robot
- name: Set Docker metadata for "desktop"
if: env.PUSH == 'true'
id: meta-desktop
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
bake-target: docker-metadata-action-desktop
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-desktop
- name: Set Docker metadata for "desktop-nvidia"
if: env.PUSH == 'true'
id: meta-desktop-nvidia
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
bake-target: docker-metadata-action-desktop-nvidia
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-desktop-nvidia
- if: github.event_name == 'push'
name: Build and push (non PR)
uses: docker/[email protected]
env:
BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }}
BLUE_GITHUB_REPO: ${{ steps.lowercase-repo.outputs.repository }}
with:
workdir: .docker
files: |
./docker-bake.hcl
${{ steps.meta-ci.outputs.bake-file }}
${{ steps.meta-robot.outputs.bake-file }}
${{ steps.meta-desktop.outputs.bake-file }}
${{ steps.meta-desktop-nvidia.outputs.bake-file }}
push: ${{ env.PUSH }}
set: |
*.cache-from=type=registry,ref=ghcr.io/${{ steps.lowercase-repo.outputs.repository }}:cache-${{ matrix.ROS_DISTRO }}
*.cache-to=type=registry,mode=max,ref=ghcr.io/${{ steps.lowercase-repo.outputs.repository }}:cache-${{ matrix.ROS_DISTRO }}
# Pull request builds are not cached; and only built for AMD64
- if: github.event_name == 'pull_request'
name: Build and push (PR)
uses: docker/[email protected]
env:
BLUE_ROS_DISTRO: ${{ matrix.ROS_DISTRO }}
BLUE_GITHUB_REPO: ${{ steps.lowercase-repo.outputs.repository }}
with:
workdir: .docker
files: |
./docker-bake.hcl
set: |
*.platform=linux/amd64
*.cache-from=type=registry,ref=ghcr.io/${{ steps.lowercase-repo.outputs.repository }}:cache-${{ matrix.ROS_DISTRO }}
*.cache-to=