forked from abrasive/shairport
-
-
Notifications
You must be signed in to change notification settings - Fork 574
121 lines (102 loc) · 3.82 KB
/
docker-build-on-push_and_pull_request.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
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
# Builds a docker image when a commit is made. Also pushes the build if the branch is 'master' or 'development'.
# Tag pattern
# 'master' - rolling, rolling-classic
# 'development' - development, development-classic
name: Build and push docker (push/pull request)
on:
push:
branches:
- master
- development
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
env:
DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
NQPTP_BRANCH: main
jobs:
test-build-on-pull-request:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Set SHAIRPORT_SYNC_BRANCH env
run: |
SHAIRPORT_SYNC_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Current SHAIRPORT_SYNC_BRANCH set to ${SHAIRPORT_SYNC_BRANCH}"
echo "SHAIRPORT_SYNC_BRANCH=${SHAIRPORT_SYNC_BRANCH}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build (classic)
uses: docker/[email protected]
with:
context: ./
file: ./docker/classic/Dockerfile
push: false
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
- name: Build
uses: docker/[email protected]
with:
context: ./
file: ./docker/Dockerfile
push: false
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
NQPTP_BRANCH=${{ env.NQPTP_BRANCH }}
build-and-publish:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set SHAIRPORT_SYNC_BRANCH env.
run: echo "SHAIRPORT_SYNC_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Is branch "master"?
if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'master' }}
run: |
echo "IMAGE_TAG_BASE=rolling" >> $GITHUB_ENV
- name: Is branch "development"?
if: ${{ env.SHAIRPORT_SYNC_BRANCH == 'development' }}
run: |
echo "NQPTP_BRANCH=development" >> $GITHUB_ENV
echo "IMAGE_TAG_BASE=development" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to Docker Registry
uses: docker/[email protected]
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
- name: Build and push (classic)
uses: docker/[email protected]
with:
context: ./
file: ./docker/classic/Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ env.IMAGE_TAG_BASE != '' }}
tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.IMAGE_TAG_BASE }}-classic
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
- name: Build and push
uses: docker/[email protected]
with:
context: ./
file: ./docker/Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ env.IMAGE_TAG_BASE != '' }}
tags: ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.IMAGE_TAG_BASE }}
build-args: |
SHAIRPORT_SYNC_BRANCH=${{ env.SHAIRPORT_SYNC_BRANCH }}
NQPTP_BRANCH=${{ env.NQPTP_BRANCH }}