-
Notifications
You must be signed in to change notification settings - Fork 488
193 lines (180 loc) · 6.95 KB
/
Copy pathbuild.yml
File metadata and controls
193 lines (180 loc) · 6.95 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Build Docker Images
on:
push:
paths:
- 'docker-images/**'
- 'templates/**'
- '.github/workflows/build.yml'
pull_request:
paths:
- 'docker-images/**'
- 'templates/**'
- '.github/workflows/build.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
pages: write
id-token: write
env:
DOCKER: jrottenberg/ffmpeg
GHCR: ghcr.io/jrottenberg/ffmpeg
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- run: pip install pre-commit packaging
- uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- run: pre-commit run --all-files --show-diff-on-failure
generate-matrix:
runs-on: ubuntu-latest
outputs:
build: ${{ steps.matrix.outputs.build }}
manifest: ${{ steps.matrix.outputs.manifest }}
steps:
- uses: actions/checkout@v6
- id: matrix
run: |
echo "build=$(jq -c '.build' docker-images/github-actions-matrix.json)" >> "$GITHUB_OUTPUT"
echo "manifest=$(jq -c '.manifest' docker-images/github-actions-matrix.json)" >> "$GITHUB_OUTPUT"
build:
needs: [lint, generate-matrix]
runs-on: ${{ matrix.runner }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.build) }}
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/login-action@v4
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v7
with:
context: docker-images/${{ matrix.version }}/${{ matrix.variant }}
platforms: ${{ matrix.platform }}
push: ${{ github.event_name == 'push' }}
tags: |
${{ env.DOCKER }}:${{ matrix.long_version }}-${{ matrix.variant }}-${{ matrix.arch }}
${{ env.GHCR }}:${{ matrix.long_version }}-${{ matrix.variant }}-${{ matrix.arch }}
cache-from: type=gha,scope=${{ matrix.version }}-${{ matrix.variant }}-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.version }}-${{ matrix.variant }}-${{ matrix.arch }}
- name: Load image for smoke test
uses: docker/build-push-action@v7
with:
context: docker-images/${{ matrix.version }}/${{ matrix.variant }}
load: true
tags: smoke-test:latest
cache-from: type=gha,scope=${{ matrix.version }}-${{ matrix.variant }}-${{ matrix.arch }}
- name: Smoke test
run: |
docker run --rm smoke-test:latest -version
docker run --rm smoke-test:latest -buildconf
CODECS=$(docker run --rm smoke-test:latest -codecs)
for codec in libx264 libx265 libvpx libopus; do
echo "Checking $codec..."
echo "$CODECS" | grep -q "$codec" || { echo "MISSING: $codec"; exit 1; }
done
echo "All codec checks passed"
create-manifests:
if: github.event_name == 'push'
needs: [build, generate-matrix]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.manifest) }}
steps:
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create multi-arch manifests
env:
PLATFORMS: ${{ matrix.platforms }}
VARIANT: ${{ matrix.variant }}
PARENT: ${{ matrix.parent }}
VERSION: ${{ matrix.version }}
LONG_VERSION: ${{ matrix.long_version }}
MAJOR_VERSION: ${{ matrix.major_version }}
ISPARENT: ${{ matrix.is_parent }}
ISLATEST: ${{ matrix.is_latest }}
run: |
DOCKER_SOURCES=""
GHCR_SOURCES=""
IFS=',' read -ra ARCHS <<< "${PLATFORMS}"
for platform in "${ARCHS[@]}"; do
arch="${platform#linux/}"
DOCKER_SOURCES="${DOCKER_SOURCES} ${{ env.DOCKER }}:${LONG_VERSION}-${VARIANT}-${arch}"
GHCR_SOURCES="${GHCR_SOURCES} ${{ env.GHCR }}:${LONG_VERSION}-${VARIANT}-${arch}"
done
DOCKER_TAGS="${{ env.DOCKER }}:${VERSION}-${VARIANT} ${{ env.DOCKER }}:${LONG_VERSION}-${VARIANT}"
GHCR_TAGS="${{ env.GHCR }}/${VERSION}-${VARIANT} ${{ env.GHCR }}/${LONG_VERSION}-${VARIANT}"
if [ "${ISPARENT}" == "True" ] && [ "${VARIANT}" != "${PARENT}" ]; then
DOCKER_TAGS="${DOCKER_TAGS} ${{ env.DOCKER }}:${VERSION}-${PARENT} ${{ env.DOCKER }}:${MAJOR_VERSION}-${PARENT}"
GHCR_TAGS="${GHCR_TAGS} ${{ env.GHCR }}:${VERSION}-${PARENT} ${{ env.GHCR }}:${MAJOR_VERSION}-${PARENT}"
fi
if [ "${ISLATEST}" == "True" ]; then
DOCKER_TAGS="${DOCKER_TAGS} ${{ env.DOCKER }}:latest"
GHCR_TAGS="${GHCR_TAGS} ${{ env.GHCR }}:latest"
fi
for tag in ${DOCKER_TAGS}; do
docker buildx imagetools create -t "${tag}" ${DOCKER_SOURCES}
done
for tag in ${GHCR_TAGS}; do
docker buildx imagetools create -t "${tag}" ${GHCR_SOURCES}
done
deploy-docs:
if: github.event_name != 'pull_request'
needs: [lint]
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v6
- name: Sync README and CONTRIBUTING to docs
run: |
mkdir -p docs
printf -- '---\nlayout: default\ntitle: FFmpeg Docker Images\n---\n\n' > docs/index.md
cat README.md >> docs/index.md
printf -- '---\nlayout: default\ntitle: Contributing\n---\n\n' > docs/contributing.md
cat CONTRIBUTING.md >> docs/contributing.md
- uses: actions/configure-pages@v6
- uses: actions/jekyll-build-pages@v1
with:
source: ./docs
destination: ./_site
- uses: actions/upload-pages-artifact@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5