Skip to content

CI

CI #1937

Workflow file for this run

name: CI
on:
push:
pull_request:
workflow_dispatch:
inputs:
type:
description: 'Type (edge/proxy)'
default: 'edge'
required: true
jobs:
variables:
runs-on: ubuntu-latest
outputs:
ARCH_LIST: ${{ env.ARCH_LIST }}
ADDON_LIST: ${{ env.ADDON_LIST }}
DOCKER_ARGS: ${{ env.DOCKER_ARGS }}
steps:
- uses: actions/checkout@v3
- name: "ARGS: default"
run: |
echo "ADDON_LIST=['zigbee2mqtt', 'zigbee2mqtt-edge']" >> $GITHUB_ENV
echo "DOCKER_ARGS=--no-latest --test" >> $GITHUB_ENV
- name: "ARGS: zigbee2mqtt-proxy" # Build of addon proxy version
if: github.ref == 'refs/heads/master' && (github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'proxy')
run: |
echo "ADDON_LIST=['zigbee2mqtt-proxy']" >> $GITHUB_ENV
echo "DOCKER_ARGS=--no-cache" >> $GITHUB_ENV
- name: "ARGS: zigbee2mqtt-edge" # Build of addon edge version
if: github.ref == 'refs/heads/master' && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'edge'))
run: |
echo "ADDON_LIST=['zigbee2mqtt-edge']" >> $GITHUB_ENV
echo "DOCKER_ARGS=--no-cache" >> $GITHUB_ENV
- name: "ARGS: zigbee2mqtt" # Build of addon release version
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
run: |
echo "ADDON_LIST=['zigbee2mqtt']" >> $GITHUB_ENV
echo "DOCKER_ARGS=--no-cache --docker-hub-check" >> $GITHUB_ENV
- name: Determine arch
id: determine_arch
run: |
ARCH_LIST=$(jq -r -c '.arch' ./${{ fromJSON(env.ADDON_LIST)[0] }}/config.json)
echo "Found the following arches: $ARCH_LIST"
echo "ARCH_LIST=$ARCH_LIST" >> $GITHUB_ENV
build:
runs-on: ubuntu-latest
needs: variables
env:
DOCKER_ARGS: ${{needs.variables.outputs.DOCKER_ARGS}}
strategy:
matrix:
arch: ${{fromJSON(needs.variables.outputs.ARCH_LIST)}}
addon: ${{fromJSON(needs.variables.outputs.ADDON_LIST)}}
steps:
- uses: actions/checkout@v3
- name: Docker login
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
run: echo ${{ secrets.DOCKER_KEY }} | docker login -u koenkk --password-stdin
- name: Build
run: |
if [ "${{ matrix.addon }}" != "zigbee2mqtt-proxy" ]; then
cp -R common/rootfs ${{ matrix.addon }}
cp common/Dockerfile ${{ matrix.addon }}
fi
cp common/build.yaml ${{ matrix.addon }}
docker run --rm --privileged \
-v /home/runner/.docker:/root/.docker \
-v /run/docker.sock:/run/docker.sock:rw \
-v $(pwd)/${{ matrix.addon }}:/data homeassistant/amd64-builder --${{ matrix.arch }} -t /data \
${{ env.DOCKER_ARGS }}