forked from abrasive/shairport
-
-
Notifications
You must be signed in to change notification settings - Fork 564
87 lines (73 loc) · 2.74 KB
/
docker-build-on-tag.yaml
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
# Builds & pushes a docker image when a tag is created.
# Tag pattern: '[tag]' & '[tag]-classic'
# 'latest' & 'classic' also, when master tagged.
# Only pushes the tag when it matches one of the following patterns:
# X, X.Y or X.Y.Z
name: Build and push docker (tag)
on:
workflow_dispatch:
push:
tags:
- '[0-9]+' # X
- '[0-9]+\.[0-9]+' # X.Y
- '[0-9]+\.[0-9]+\.[0-9]+' # X.Y.Z
env:
DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm64,linux/arm/v7
NQPTP_BRANCH: main
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
- name: Set SHAIRPORT_SYNC_BRANCH env.
run: |
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw##*/}
echo "SHAIRPORT_SYNC_BRANCH=${branch}" >> $GITHUB_ENV
- name: Set tag env
run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Is branch "master"?
if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'master' }}
run: echo "LATEST_TAG=true" >> $GITHUB_ENV
- name: Is branch "development"?
if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'development' }}
run: |
echo "NQPTP_BRANCH=development" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.5.0
- name: Login to Docker Registry
uses: docker/login-action@v2.1.0
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
- name: Build and push (classic)
uses: docker/build-push-action@v4.0.0
with:
context: ./
file: ./docker/classic/Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
tags: |
${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GIT_TAG }}-classic
${{ env.LATEST_TAG == 'true' && format('{0}:classic', secrets.DOCKER_IMAGE_NAME) || '' }}
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
- name: Build and push
uses: docker/build-push-action@v4.0.0
with:
context: ./
file: ./docker/Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
tags: |
${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GIT_TAG }}
${{ env.LATEST_TAG == 'true' && format('{0}:latest', secrets.DOCKER_IMAGE_NAME) || '' }}
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
NQPTP_BRANCH=${{ env.NQPTP_BRANCH }}