-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (44 loc) · 1.52 KB
/
image.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
name: 'build image'
on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for any PRs.
pull_request:
# Build image once a week to apply updates in base image.
schedule:
- cron: 0 0 */7 * *
env:
IMAGE_NAME: ${{github.repository}}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'checkout code'
uses: actions/checkout@v2
- name: 'install buildx'
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
- name: 'login to docker hub'
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: build ${{github.repository}}
run: |
GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
# Change all uppercase to lowercase
IMAGE_NAME=$(echo $IMAGE_NAME | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
docker buildx build . --push \
--tag thedolt/openhab-cloud:$GIT_HASH \
--tag thedolt/openhab-cloud:latest \
--platform linux/amd64,linux/arm/v7,linux/arm64/v8