-
-
Notifications
You must be signed in to change notification settings - Fork 228
134 lines (117 loc) · 4.41 KB
/
Copy pathdocker-build.yml
File metadata and controls
134 lines (117 loc) · 4.41 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
127
128
129
130
131
132
133
134
name: Build and Publish Docker
on:
push:
branches:
- "**"
tags:
- "*"
paths-ignore:
- "docs/**"
- "*.md"
workflow_dispatch:
jobs:
build:
name: Build ${{ matrix.arch }} image
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-latest
- arch: arm64
platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Prepare build variables
id: build
run: |
echo "image_repository=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "${GITHUB_OUTPUT}"
echo "image_name=fpp" >> "${GITHUB_OUTPUT}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push image by digest
id: docker-build
uses: docker/build-push-action@v7
with:
context: .
file: ./Docker/Dockerfile
build-args: |
FPPBRANCH=${{ github.ref_name }}
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ steps.build.outputs.image_repository }}/${{ steps.build.outputs.image_name }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=fpp-build-docker-${{ matrix.arch }}
cache-to: type=gha,scope=fpp-build-docker-${{ matrix.arch }},mode=max
- name: Export digest
run: |
mkdir -p "${{ runner.temp }}/digests"
digest="${{ steps.docker-build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.arch }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Create multi-arch manifest and push
runs-on: ubuntu-latest
needs:
- build
permissions:
contents: read
steps:
- name: Prepare build variables
id: build
run: |
echo "release_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "${GITHUB_OUTPUT}"
echo "image_repository=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "${GITHUB_OUTPUT}"
echo "image_name=fpp" >> "${GITHUB_OUTPUT}"
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
flavor: |
latest=false
images: ${{ steps.build.outputs.image_repository }}/${{ steps.build.outputs.image_name }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch,enable={{is_not_default_branch}}
type=ref,event=tag
labels: |
org.opencontainers.image.created=${{ steps.build.outputs.release_date }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ github.ref_name }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ steps.build.outputs.image_repository }}/${{ steps.build.outputs.image_name }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ steps.build.outputs.image_repository }}/${{ steps.build.outputs.image_name }}:${{ steps.meta.outputs.version }}