Skip to content

Commit

Permalink
Move from azure pipelines to github action for CI (home-assistant#1646)
Browse files Browse the repository at this point in the history
* Move from azure pipelines to github action for CI

* pin version

* pin directly
  • Loading branch information
ludeeus authored Oct 25, 2020
1 parent 4ee8832 commit 8b7dc6d
Show file tree
Hide file tree
Showing 29 changed files with 170 additions and 653 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/start_supervisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function cleanup_hass_data() {

function cleanup_docker() {
echo "Cleaning up stopped containers..."
docker rm $(docker ps -a -q)
docker rm "$(docker ps -a -q)"
}

function cleanup_lastboot() {
Expand Down
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
time: "06:00"
open-pull-requests-limit: 10
72 changes: 0 additions & 72 deletions .github/workflows/build.yml

This file was deleted.

109 changes: 109 additions & 0 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 52 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .shellcheckrc

This file was deleted.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Home Assistant Add-ons: The official repository

[![Build Status](https://dev.azure.com/home-assistant/Hass.io/_apis/build/status/addons?branchName=master)](https://dev.azure.com/home-assistant/Hass.io/_build/latest?definitionId=7&branchName=master)

Add-ons for Home Assistant, allow you to extend the functionality
around your Home Assistant setup. These add-ons can consist of an application
that Home Assistant can integrate with (e.g., a MQTT broker or database server)
Expand Down
28 changes: 0 additions & 28 deletions ada/azure-pipelines.yml

This file was deleted.

28 changes: 0 additions & 28 deletions almond/azure-pipelines.yml

This file was deleted.

54 changes: 0 additions & 54 deletions azure-pipelines.yml

This file was deleted.

Loading

0 comments on commit 8b7dc6d

Please sign in to comment.