Repository navigation
130 lines (113 loc) · 4.7 KB
/
Copy pathdocker.yml
File metadata and controls
130 lines (113 loc) · 4.7 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
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT
name: Docker image
on:
release:
types: [published]
push:
branches:
- main
- master
- stable*
env:
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/whiteboard
jobs:
build:
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
strategy:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-22.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- name: Set vars
id: vars
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
echo "version_channel=beta" >> $GITHUB_OUTPUT
else
echo "version_channel=stable" >> $GITHUB_OUTPUT
fi
else
echo "version_channel=daily" >> $GITHUB_OUTPUT
fi
echo "version=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "version_ref=${{ github.event_name == 'release' && github.ref_name || github.sha }}" >> $GITHUB_OUTPUT
echo "created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
echo "platform=$(echo -n ${{ matrix.platform }} | sed 's/\//-/g')" >> $GITHUB_OUTPUT
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Login to Github Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker images
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
push: true
platforms: ${{ matrix.platform }}
provenance: false
build-args: |
VERSION=${{ steps.vars.outputs.version_ref }}
REVISION=${{ github.sha }}
CREATED=${{ steps.vars.outputs.created }}
tags: |
${{ env.GHCR_REPO}}:${{ steps.vars.outputs.version }}-${{ steps.vars.outputs.platform }}
release:
runs-on: ubuntu-22.04
timeout-minutes: 10
needs: build
steps:
- name: Set vars
id: vars
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
echo "version_channel=beta" >> $GITHUB_OUTPUT
else
echo "version_channel=stable" >> $GITHUB_OUTPUT
fi
else
echo "version_channel=daily" >> $GITHUB_OUTPUT
fi
echo "version_ref=${{ github.event_name == 'release' && github.ref_name || github.sha }}" >> $GITHUB_OUTPUT
echo "version=${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Login to Github Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create GHCR manifest
run: |
# Create manifest for the specific version (tag name or commit SHA)
docker manifest create $GHCR_REPO:${{ steps.vars.outputs.version_ref }} \
$GHCR_REPO:${{ steps.vars.outputs.version }}-linux-amd64 \
$GHCR_REPO:${{ steps.vars.outputs.version }}-linux-arm64
# Create manifest for the channel (release, prerelease, or daily)
docker manifest create $GHCR_REPO:${{ steps.vars.outputs.version_channel }} \
$GHCR_REPO:${{ steps.vars.outputs.version }}-linux-amd64 \
$GHCR_REPO:${{ steps.vars.outputs.version }}-linux-arm64
# Create 'latest' tag only for stable releases (not pre-releases)
if [[ "${{ steps.vars.outputs.version_channel }}" == "stable" ]]; then
docker manifest create $GHCR_REPO:latest \
$GHCR_REPO:${{ steps.vars.outputs.version }}-linux-amd64 \
$GHCR_REPO:${{ steps.vars.outputs.version }}-linux-arm64
fi
- name: Push manifests
run: |
docker manifest push $GHCR_REPO:${{ steps.vars.outputs.version_ref }}
docker manifest push $GHCR_REPO:${{ steps.vars.outputs.version_channel }}
# Push 'latest' tag only for stable releases
if [[ "${{ steps.vars.outputs.version_channel }}" == "stable" ]]; then
docker manifest push $GHCR_REPO:latest
fi