mirror of
https://github.com/aljazceru/addons.git
synced 2026-02-01 03:05:49 +01:00
Move from azure pipelines to github action for CI (#1646)
* Move from azure pipelines to github action for CI * pin version * pin directly
This commit is contained in:
72
.github/workflows/build.yml
vendored
72
.github/workflows/build.yml
vendored
@@ -1,72 +0,0 @@
|
||||
name: Build
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
init:
|
||||
runs-on: ubuntu-latest
|
||||
name: Initialize builds
|
||||
outputs:
|
||||
changed_files: ${{ steps.changed_files.outputs.all }}
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get changed files
|
||||
id: changed_files
|
||||
uses: jitterbit/get-changed-files@v1
|
||||
|
||||
build:
|
||||
needs: init
|
||||
runs-on: ubuntu-latest
|
||||
name: Build ${{ matrix.addon }} add-on
|
||||
outputs:
|
||||
changed: ${{ steps.changed.outputs.changed }}
|
||||
strategy:
|
||||
fail-fast: False
|
||||
matrix:
|
||||
addon:
|
||||
- ada
|
||||
- almond
|
||||
- cec_scan
|
||||
- check_config
|
||||
- configurator
|
||||
- deconz
|
||||
- dhcp_server
|
||||
- dnsmasq
|
||||
- duckdns
|
||||
- git_pull
|
||||
- google_assistant
|
||||
- homematic
|
||||
- letsencrypt
|
||||
- mariadb
|
||||
- mosquitto
|
||||
- nginx_proxy
|
||||
- rpc_shutdown
|
||||
- samba
|
||||
- ssh
|
||||
- tellstick
|
||||
- zwave
|
||||
steps:
|
||||
- name: Check if ${{ matrix.addon }} was changed
|
||||
id: changed
|
||||
run: |
|
||||
if [[ "${{ needs.init.outputs.changed_files }}" =~ "${{ matrix.addon }}" ]]; then
|
||||
echo "::set-output name=changed::true"
|
||||
fi
|
||||
|
||||
- name: Check out repository
|
||||
if: steps.changed.outputs.changed == 'true'
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Test docker build for ${{ matrix.addon }}
|
||||
if: steps.changed.outputs.changed == 'true'
|
||||
uses: home-assistant/builder@master
|
||||
with:
|
||||
args: |
|
||||
--test \
|
||||
--all \
|
||||
--target /data/${{ matrix.addon }}
|
||||
109
.github/workflows/builder.yml
vendored
Normal file
109
.github/workflows/builder.yml
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
name: Build add-on
|
||||
|
||||
env:
|
||||
BUILD_ARGS: "--test"
|
||||
MONITORED_FILES: "apparmor.txt build.json config.json Dockerfile data rootfs"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ["master"]
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
jobs:
|
||||
init:
|
||||
runs-on: ubuntu-latest
|
||||
name: Initialize builds
|
||||
outputs:
|
||||
changed_files: ${{ steps.changed_files.outputs.all }}
|
||||
changed_addons: ${{ steps.changed_addons.outputs.addons }}
|
||||
changed: ${{ steps.changed_addons.outputs.changed }}
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get changed files
|
||||
id: changed_files
|
||||
uses: jitterbit/get-changed-files@v1
|
||||
|
||||
- name: Get add-ons
|
||||
id: addons
|
||||
run: |
|
||||
addons=$(find ./ -name config.json | cut -d "/" -f2 | sort -u)
|
||||
echo "::set-output name=addons::$addons"
|
||||
|
||||
- name: Get changed add-ons
|
||||
id: changed_addons
|
||||
run: |
|
||||
declare -a changed_addons
|
||||
for addon in ${{ steps.addons.outputs.addons }}; do
|
||||
if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon ]]; then
|
||||
for file in ${{ env.MONITORED_FILES }}; do
|
||||
if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon/$file ]]; then
|
||||
changed_addons+=("\"${addon}\",");
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev)
|
||||
echo "::set-output name=addons::[$changed]"
|
||||
if [[ ! -z ${changed} ]]; then
|
||||
echo "Changed add-ons: $changed"
|
||||
echo "::set-output name=changed::true"
|
||||
else
|
||||
echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})"
|
||||
fi
|
||||
|
||||
build:
|
||||
needs: init
|
||||
runs-on: ubuntu-latest
|
||||
if: needs.init.outputs.changed == 'true'
|
||||
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on
|
||||
strategy:
|
||||
matrix:
|
||||
addon: ${{ fromJson(needs.init.outputs.changed_addons) }}
|
||||
arch: ["aarch64", "amd64", "armhf", "armv7", "i386"]
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get information
|
||||
id: info
|
||||
uses: home-assistant/actions/helpers/info@master
|
||||
with:
|
||||
path: "./${{ matrix.addon }}"
|
||||
|
||||
- name: Check add-on
|
||||
id: check
|
||||
run:
|
||||
if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then
|
||||
echo "::set-output name=buld_arch::true";
|
||||
else
|
||||
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"
|
||||
fi
|
||||
|
||||
- name: Set build arguments
|
||||
if: steps.check.outputs.buld_arch == 'true'
|
||||
run: |
|
||||
if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then
|
||||
echo "BUILD_ARGS=--docker-hub-check" >> $GITHUB_ENV;
|
||||
fi
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: env.BUILD_ARGS == '--docker-hub-check'
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build ${{ matrix.addon }} add-on
|
||||
if: steps.check.outputs.buld_arch == 'true'
|
||||
uses: home-assistant/builder@master
|
||||
with:
|
||||
args: |
|
||||
${{ env.BUILD_ARGS }} \
|
||||
--${{ matrix.arch }} \
|
||||
--target /data/${{ matrix.addon }} \
|
||||
--docker-hub homeassistant
|
||||
52
.github/workflows/lint.yml
vendored
Normal file
52
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
name: Lint
|
||||
|
||||
env:
|
||||
HADOLINT_VERSION: v1.17.2
|
||||
SHELLCHECK_OPTS: -e SC1008 -s bash
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ["master"]
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
jobs:
|
||||
hadolint:
|
||||
runs-on: ubuntu-latest
|
||||
name: hadolint
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run linter
|
||||
id: changed_files
|
||||
run: |
|
||||
shopt -s globstar
|
||||
for dockerfile in **/Dockerfile; do
|
||||
echo "Linting: $dockerfile"
|
||||
docker run --rm -i \
|
||||
-v $(pwd)/.hadolint.yaml:/.hadolint.yaml:ro \
|
||||
hadolint/hadolint:${{ env.HADOLINT_VERSION }} < "$dockerfile"
|
||||
done
|
||||
|
||||
jq:
|
||||
runs-on: ubuntu-latest
|
||||
name: JQ
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run linter
|
||||
run: |
|
||||
shopt -s globstar
|
||||
cat **/*.json | jq '.'
|
||||
|
||||
shellcheck:
|
||||
runs-on: ubuntu-latest
|
||||
name: ShellCheck
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run linter
|
||||
uses: ludeeus/action-shellcheck@0.5.0
|
||||
Reference in New Issue
Block a user