Repository navigation
126 lines (109 loc) · 4.57 KB
/
Copy pathdocker.yml
File metadata and controls
126 lines (109 loc) · 4.57 KB
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
name: docker
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
workflow_dispatch:
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
packages: write
jobs:
build:
name: build ${{ matrix.image }} (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
- { image: rover-ros, arch: amd64, runner: ubuntu-24.04, platform: linux/amd64, context: ., file: docker/ros/Dockerfile, target: rover-ros }
- { image: rover-ros, arch: arm64, runner: ubuntu-24.04-arm, platform: linux/arm64, context: ., file: docker/ros/Dockerfile, target: rover-ros }
- { image: rover-mavlink-router, arch: amd64, runner: ubuntu-24.04, platform: linux/amd64, context: docker/mavlink-router, file: docker/mavlink-router/Dockerfile, target: '' }
- { image: rover-mavlink-router, arch: arm64, runner: ubuntu-24.04-arm, platform: linux/arm64, context: docker/mavlink-router, file: docker/mavlink-router/Dockerfile, target: '' }
steps:
- uses: actions/checkout@v4
- name: Registry name (lower case owner)
id: reg
run: echo "name=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${{ matrix.image }}" >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@v3
- name: Log in to ghcr.io
if: github.event_name != 'pull_request'
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
with:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
target: ${{ matrix.target }}
platforms: ${{ matrix.platform }}
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
outputs: type=image,name=${{ steps.reg.outputs.name }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
cache-from: type=gha,scope=${{ matrix.image }}-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.image }}-${{ matrix.arch }}
- name: Export digest
if: github.event_name != 'pull_request'
run: |
mkdir -p "${RUNNER_TEMP}/digests"
digest="${{ steps.build.outputs.digest }}"
touch "${RUNNER_TEMP}/digests/${digest#sha256:}"
- name: Upload digest
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.image }}-${{ matrix.arch }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
manifest:
name: manifest ${{ matrix.image }}
if: github.event_name != 'pull_request'
needs: build
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
image: [ rover-ros, rover-mavlink-router ]
steps:
- name: Registry name (lower case owner)
id: reg
run: echo "name=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${{ matrix.image }}" >> "$GITHUB_OUTPUT"
- uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-${{ matrix.image }}-*
merge-multiple: true
- uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ steps.reg.outputs.name }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=sha-,format=short
type=semver,pattern={{version}}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list
working-directory: ${{ runner.temp }}/digests
env:
REGISTRY_IMAGE: ${{ steps.reg.outputs.name }}
run: |
tags=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")
# shellcheck disable=SC2046,SC2086
docker buildx imagetools create $tags $(printf "${REGISTRY_IMAGE}@sha256:%s " *)
- name: Inspect
run: docker buildx imagetools inspect "${{ steps.reg.outputs.name }}:${{ steps.meta.outputs.version }}"