This repository has been archived by the owner on Aug 23, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (79 loc) · 3.22 KB
/
dockerbuild.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Docker Build
on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- master
pull_request:
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
wget -q https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip
unzip pup_v0.4.0_linux_amd64.zip
wget -q http://old.openzwave.com/downloads/ -O downloads.html
EXISTING_TAGS=$(wget -q https://registry.hub.docker.com/v1/repositories/chrisns/openzwave/tags -O -)
MATRIX="{\"openzwave\":[\"git\""
for i in {2..4}
do
VERSION=$(cat downloads.html | ./pup '#pagecontent > table:nth-child(2) > tbody > tr:nth-child('${i}') > td:nth-child(1) text{}')
if [[ $EXISTING_TAGS != *"$VERSION"* ]]
then
echo ADDING $VERSION TO MATRIX
MATRIX="${MATRIX},\"${VERSION}\""
else
echo SKIPPING ${VERSION}
fi
done
MATRIX="${MATRIX}],\"dockerfile\":[\"alpine\",\"debian\",\"ubuntu\",\"centos8\"]}"
echo $MATRIX
echo "::set-output name=matrix::$MATRIX"
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
needs:
- matrix
steps:
- name: Set tag
run: echo "BUILD_TAG=${{ matrix.dockerfile }}-${{ matrix.openzwave }}" >> $GITHUB_ENV
- uses: actions/[email protected]
with:
submodules: ${{ matrix.openzwave == 'git' }}
- name: Get and extract stable ozw
if: ${{ steps.should.outputs.build == 'true' && matrix.openzwave != 'git'}}
run: |
curl -o ozw.tar.gz http://old.openzwave.com/downloads/openzwave-${{ matrix.openzwave }}.tar.gz
tar -xzvf ozw.tar.gz
rm -rf open-zwave
mv openzwave-${{ matrix.openzwave }} open-zwave
mkdir -p .git/modules/open-zwave/refs/heads
echo ${{ matrix.openzwave }} > .git/modules/open-zwave/refs/heads/master
- name: Setup some environment variables
run: |
echo BUILDPLATFORM=$([ "$GITHUB_REF" == "refs/heads/master" ] && echo $(cat SupportedArch.${{ matrix.dockerfile }}) || echo "linux/amd64") >> $GITHUB_ENV
echo OZW_VERSION=$(cat .git/modules/open-zwave/refs/heads/master) >> $GITHUB_ENV
- name: Login to dockerhub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/setup-buildx-action@v1
- uses: docker/[email protected]
- name: build+push
uses: docker/[email protected]
with:
file: Dockerfile.${{ matrix.dockerfile }}
cache-from: type=registry,ref=chrisns/openzwave:${{ matrix.dockerfile }}-sha-${{ env.OZW_VERSION }}
platforms: ${{ env.BUILDPLATFORM }}
push: ${{ github.ref == 'refs/heads/master' }}
tags: |
chrisns/openzwave:${{ matrix.dockerfile }}-${{ matrix.openzwave }}
chrisns/openzwave:${{ matrix.dockerfile }}-sha-${{ env.OZW_VERSION }}