-
Notifications
You must be signed in to change notification settings - Fork 19
71 lines (57 loc) · 2.56 KB
/
docker.yml
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
name: Docker
# Thanks to Ryan Govostes <https://github.com/rgov> for this workflow.
# Using 'if:' conditions, the script will not execute the steps
# unless it is running out of the 'mikebrady/shairport-sync-docker' GitHub repository.
on:
workflow_dispatch:
# Publish `master` as Docker `latest` image.
branches:
- master
# Publish `1.2.3` tags as releases.
tags:
- '*'
env:
IMAGE_NAME: mikebrady/shairport-sync
# DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm64
DOCKER_HUB_USER: mikebrady
jobs:
# Build the container image for multiple architectures
build:
runs-on: ubuntu-latest
steps:
# This unusual setup is due to limitations with `docker buildx`.
# See: https://github.com/crazy-max/ghaction-docker-buildx/issues/134
- name: Prepare
id: prepare
if: github.repository == 'mikebrady/shairport-sync-docker'
run: |
# Map git ref branch or tag name to Docker tag version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "master" ] && VERSION=latest && SHAIRPORT_SYNC_BRANCH=master
# If tagged with a version, build the same version of Shairport Sync
[ "$VERSION" != "latest" ] && SHAIRPORT_SYNC_BRANCH=tags/$VERSION
# Output build arguments for downstream steps
echo ::set-output name=buildx_args::\
--platform ${DOCKER_PLATFORMS} \
--build-arg SHAIRPORT_SYNC_BRANCH=${SHAIRPORT_SYNC_BRANCH} \
--tag ${IMAGE_NAME}:${VERSION} \
.
- uses: actions/checkout@v2
- uses: crazy-max/[email protected]
- name: Build
if: github.repository == 'mikebrady/shairport-sync-docker'
run: |
docker buildx build \
--output type=image,push=false \
${{ steps.prepare.outputs.buildx_args }}
- name: Log into registry
if: github.event_name == 'push' && github.repository == 'mikebrady/shairport-sync-docker'
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login --username $DOCKER_HUB_USER --password-stdin
- name: Push to registry
if: github.event_name == 'push' && github.repository == 'mikebrady/shairport-sync-docker'
run: |
docker buildx build \
--output type=image,push=true \
${{ steps.prepare.outputs.buildx_args }}