forked from moos-ivp/moos-ivp
-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (135 loc) · 4.47 KB
/
docker-publish.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: DockerPublish
on:
workflow_dispatch:
push:
env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
jobs:
build-base:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: linux/amd64
- os: ubuntu-latest # change this to the native arm runner when Github makes it public
arch: linux/arm64
steps:
- name: Prepare
run: |
platform=${{ matrix.arch }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "COMMIT_TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build base by digest for cache
id: build
uses: docker/build-push-action@v6
env:
SOURCE_DATE_EPOCH: ${{ env.COMMIT_TIMESTAMP }}
with:
platforms: ${{ matrix.platform }}
file: docker/moos-ivp/Dockerfile
target: base
cache-from: type=gha
cache-to: type=gha,mode=max
build-minrobot:
runs-on: ubuntu-latest
needs:
- build-base
env:
FLAVOR: ""
steps:
- name: Prepare
run: |
echo "COMMIT_TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
env:
SOURCE_DATE_EPOCH: ${{ env.COMMIT_TIMESTAMP }}
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
# branch event
type=ref,enable=true,prefix=${{ env.flavor }},event=branch
# tag event
type=ref,enable=true,prefix=${{ env.flavor }},event=tag
# pull request event
type=ref,enable=true,prefix=${{ env.flavor }}pr-,suffix=,event=pr
# commit sha
type=sha,prefix=${{ env.flavor }},suffix=,format=short
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
env:
SOURCE_DATE_EPOCH: ${{ env.COMMIT_TIMESTAMP }}
with:
platforms: linux/amd64,linux/arm64
annotations: ${{ steps.meta.outputs.annotations }}
file: docker/moos-ivp/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
build-gui:
runs-on: ubuntu-latest
needs:
- build-minrobot
env:
FLAVOR: "-gui"
steps:
- name: Prepare
run: |
echo "COMMIT_TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
env:
SOURCE_DATE_EPOCH: ${{ env.COMMIT_TIMESTAMP }}
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
# branch event
type=ref,enable=true,suffix=${{ env.FLAVOR }},event=branch
# tag event
type=ref,enable=true,suffix=${{ env.FLAVOR }},event=tag
# pull request event
type=ref,enable=true,suffix=pr-,suffix=${{ env.FLAVOR }},event=pr
# commit sha
type=sha,prefix=${{ env.FLAVOR }},suffix=,format=short
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
env:
SOURCE_DATE_EPOCH: ${{ env.COMMIT_TIMESTAMP }}
with:
platforms: linux/amd64,linux/arm64
annotations: ${{ steps.meta.outputs.annotations }}
build-args: |
FROM=${{ needs.build-minrobot.build.outputs.digest }}
file: docker/moos-ivp-gui/Dockerfile
cache-from: type=gha
tags: ${{ steps.meta.outputs.tags }}