-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 550ab75
Showing
24 changed files
with
909 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM ubuntu:20.04 | ||
|
||
WORKDIR /workspaces | ||
|
||
# Default ENV | ||
ENV LANG C.UTF-8 | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# Set shell | ||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
# Use the mirror protocol for a fast mirror | ||
RUN sed -i -e 's/http:\/\/archive\.ubuntu\.com\/ubuntu\//mirror:\/\/mirrors\.ubuntu\.com\/mirrors\.txt/' /etc/apt/sources.list | ||
|
||
# Install docker, jq, socat | ||
# https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/ | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
dbus \ | ||
software-properties-common \ | ||
gpg-agent \ | ||
git \ | ||
jq \ | ||
socat \ | ||
sudo \ | ||
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - \ | ||
&& add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ | ||
&& apt-get update && apt-get install -y --no-install-recommends \ | ||
docker-ce \ | ||
docker-ce-cli \ | ||
containerd.io | ||
# This is a development container. Don't bother to clean up apt cache, this way we have it handy later | ||
|
||
COPY .devcontainer/start_ha.sh /usr/local/bin/start_ha.sh | ||
|
||
# Install dependencies for the add-on development below. For example, if you're running Node.js, | ||
# you may want something like the following... | ||
# RUN apt-get install -y --no-install-recommends nodejs npm | ||
|
||
# Generate a machine-id for this container | ||
RUN rm /etc/machine-id && dbus-uuidgen --ensure=/etc/machine-id | ||
|
||
ENV DEBIAN_FRONTEND=dialog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// For format details, see https://aka.ms/vscode-remote/devcontainer.json | ||
// TODO: When https://github.com/microsoft/vscode-remote-release/issues/2129 is fixed, move to ${localWorkspaceFolderBasename}\ | ||
{ | ||
"name": "Home Assistant Add-On", | ||
"context": "..", | ||
"dockerFile": "Dockerfile", | ||
"appPort": 8123, | ||
"runArgs": [ | ||
"-e", | ||
"GIT_EDITOR=code --wait", | ||
"--privileged" | ||
], | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/test_hassio/addons/local/myaddon,type=bind,consistency=delegated", | ||
"workspaceFolder": "/workspaces/test_hassio/addons/local/myaddon", | ||
"mounts": [ | ||
// Cache docker images between devcontainer rebuilds (and share between devcontainers) | ||
"source=vsc-hassio-docker,target=/var/lib/docker,type=volume" | ||
] | ||
|
||
// Post-create command to initialize the workspace. For example, for a node.js add-on you may want: | ||
// "postCreateCommand": "cd /workspaces/test_hassio/addons/local/myaddon && npm install", | ||
// "extensions": [ | ||
// "dbaeumer.vscode-eslint", | ||
// "maty.vscode-mocha-sidebar" | ||
// ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/bin/bash | ||
set -eE | ||
|
||
DOCKER_TIMEOUT=30 | ||
DOCKER_PID=0 | ||
|
||
|
||
function start_docker() { | ||
local starttime | ||
local endtime | ||
|
||
echo "Starting docker..." | ||
dockerd 2> /dev/null & | ||
DOCKER_PID=$! | ||
|
||
echo "Waiting for docker to initialize..." | ||
starttime="$(date +%s)" | ||
endtime="$(date +%s)" | ||
until docker info >/dev/null 2>&1; do | ||
if [ $((endtime - starttime)) -le $DOCKER_TIMEOUT ]; then | ||
sleep 1 | ||
endtime=$(date +%s) | ||
else | ||
echo "Timeout while waiting for docker to come up" | ||
exit 1 | ||
fi | ||
done | ||
echo "Docker was initialized" | ||
} | ||
|
||
|
||
function stop_docker() { | ||
local starttime | ||
local endtime | ||
|
||
echo "Stopping in container docker..." | ||
if [ "$DOCKER_PID" -gt 0 ] && kill -0 "$DOCKER_PID" 2> /dev/null; then | ||
starttime="$(date +%s)" | ||
endtime="$(date +%s)" | ||
|
||
# Now wait for it to die | ||
kill "$DOCKER_PID" | ||
while kill -0 "$DOCKER_PID" 2> /dev/null; do | ||
if [ $((endtime - starttime)) -le $DOCKER_TIMEOUT ]; then | ||
sleep 1 | ||
endtime=$(date +%s) | ||
else | ||
echo "Timeout while waiting for container docker to die" | ||
exit 1 | ||
fi | ||
done | ||
else | ||
echo "Your host might have been left with unreleased resources" | ||
fi | ||
} | ||
|
||
|
||
function install() { | ||
docker pull homeassistant/amd64-hassio-supervisor:dev | ||
docker pull homeassistant/amd64-hassio-cli:dev | ||
} | ||
|
||
function cleanup_hass_data() { | ||
rm -rf /workspaces/test_hassio/{apparmor,backup,config.json,dns,dns.json,homeassistant,homeassistant.json,ingress.json,share,ssl,tmp,updater.json} | ||
rm -rf /workspaces/test_hassio/addons/{core,data,git} | ||
} | ||
|
||
function cleanup_docker() { | ||
echo "Cleaning up stopped containers..." | ||
docker rm $(docker ps -a -q) | ||
} | ||
|
||
function run_supervisor() { | ||
docker run --rm --privileged \ | ||
--name hassio_supervisor \ | ||
--security-opt seccomp=unconfined \ | ||
--security-opt apparmor:unconfined \ | ||
-v /run/docker.sock:/run/docker.sock \ | ||
-v /run/dbus:/run/dbus \ | ||
-v "/workspaces/test_hassio":/data \ | ||
-v /etc/machine-id:/etc/machine-id:ro \ | ||
-e SUPERVISOR_SHARE="/workspaces/test_hassio" \ | ||
-e SUPERVISOR_NAME=hassio_supervisor \ | ||
-e SUPERVISOR_DEV=1 \ | ||
-e HOMEASSISTANT_REPOSITORY="homeassistant/qemux86-64-homeassistant" \ | ||
homeassistant/amd64-hassio-supervisor:dev | ||
} | ||
|
||
case "$1" in | ||
"--cleanup") | ||
echo "Cleaning up old environment" | ||
cleanup_docker || true | ||
cleanup_hass_data || true | ||
exit 0;; | ||
*) | ||
echo "Creating development Home Assistant environment" | ||
start_docker | ||
trap "stop_docker" ERR | ||
install | ||
cleanup_docker || true | ||
run_supervisor | ||
stop_docker;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.sh text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
template: | | ||
## What's Changed | ||
$CHANGES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Number of days of inactivity before an issue becomes stale | ||
daysUntilStale: 60 | ||
# Number of days of inactivity before a stale issue is closed | ||
daysUntilClose: 7 | ||
# Issues with these labels will never be considered stale | ||
exemptLabels: | ||
- pinned | ||
- security | ||
# Label to use when marking an issue as stale | ||
staleLabel: stale | ||
# Comment to post when marking an issue as stale. Set to `false` to disable | ||
markComment: > | ||
This issue has been automatically marked as stale because it has not had | ||
recent activity. It will be closed if no further activity occurs. Thank you | ||
for your contributions. | ||
# Comment to post when closing a stale issue. Set to `false` to disable | ||
closeComment: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Build plugin | ||
|
||
on: | ||
pull_request: | ||
branches: ["main"] | ||
release: | ||
types: ["published"] | ||
push: | ||
branches: ["main"] | ||
paths: | ||
- Dockerfile | ||
- build.json | ||
- docker-entrypoint.sh | ||
- config.json | ||
- vault.hcl.template | ||
|
||
env: | ||
BUILD_NAME: ha-addon-vault | ||
BUILD_TYPE: plugin | ||
|
||
jobs: | ||
init: | ||
name: Initialize build | ||
runs-on: ubuntu-latest | ||
outputs: | ||
architectures: ${{ steps.info.outputs.architectures }} | ||
version: ${{ steps.version.outputs.version }} | ||
channel: ${{ steps.version.outputs.channel }} | ||
publish: ${{ steps.version.outputs.publish }} | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get information | ||
id: info | ||
uses: home-assistant/actions/helpers/info@master | ||
|
||
- name: Get version | ||
id: version | ||
uses: home-assistant/actions/helpers/version@master | ||
with: | ||
type: ${{ env.BUILD_TYPE }} | ||
|
||
build: | ||
name: Build ${{ matrix.arch }} plugin | ||
needs: init | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
arch: ${{ fromJson(needs.init.outputs.architectures) }} | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to DockerHub | ||
if: needs.init.outputs.publish == 'true' | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set build arguments | ||
if: needs.init.outputs.publish == 'false' | ||
run: echo "BUILD_ARGS=--test" >> $GITHUB_ENV | ||
|
||
- name: Build plugin | ||
uses: home-assistant/[email protected] | ||
with: | ||
args: | | ||
$BUILD_ARGS \ | ||
--${{ matrix.arch }} \ | ||
--target /data \ | ||
--generic ${{ needs.init.outputs.version }} | ||
publish: | ||
name: publish addon | ||
needs: ["init", "build"] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v2 | ||
- name: Initialize git | ||
if: needs.init.outputs.publish == 'true' | ||
uses: home-assistant/actions/helpers/git-init@master | ||
with: | ||
name: ${{ secrets.GIT_NAME }} | ||
email: ${{ secrets.GIT_EMAIL }} | ||
token: ${{ secrets.GIT_TOKEN }} | ||
- name: publish addon | ||
shell: bash | ||
if: needs.init.outputs.publish == 'true' | ||
env: | ||
VERSION: ${{ needs.init.outputs.version }} | ||
run: | | ||
if [[ "$GITHUB_EVENT_NAME" = "release" ]]; then | ||
REPO_CHANNEL="ha-addons" | ||
else | ||
REPO_CHANNEL="ha-addons-dev" | ||
fi | ||
REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") | ||
rm -rf ha-addons | ||
git clone https://github.com/tidalf/$REPO_CHANNEL ha-addons | ||
mkdir -p ha-addons/$REPOSITORY_NAME 2>/dev/null | ||
cp CHANGELOG.md README.md logo.png icon.png ha-addons/$REPOSITORY_NAME | ||
jq --arg version "$VERSION" '.version = $version' config.json > ha-addons/$REPOSITORY_NAME/config.json | ||
cd ha-addons | ||
git add $REPOSITORY_NAME | ||
git commit -m "Automatic publish ($GITHUB_EVENT_NAME) from github.com/tidalf/ha-addon-vault" | ||
git push origin main | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Release Drafter | ||
|
||
on: | ||
push: | ||
# branches to consider in the event; optional, defaults to all | ||
branches: | ||
- master | ||
|
||
jobs: | ||
update_release_draft: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: release-drafter/release-drafter@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Lint | ||
|
||
env: | ||
SHELLCHECK_OPTS: -e SC1008 -e SC2046 -s bash | ||
|
||
on: | ||
pull_request: | ||
branches: ["master"] | ||
push: | ||
branches: ["master"] | ||
|
||
jobs: | ||
shellcheck: | ||
runs-on: ubuntu-latest | ||
name: ShellCheck | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run linter | ||
uses: ludeeus/[email protected] | ||
with: | ||
additional_files: 'run' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
hassio-addon-vault/terraform/.terraform/* | ||
hassio-addon-vault/terraform/terraform.tfstate* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "pwa-chrome", | ||
"request": "launch", | ||
"name": "Launch Chrome against localhost", | ||
"url": "http://localhost:8080", | ||
"webRoot": "${workspaceFolder}" | ||
} | ||
] | ||
} |
Oops, something went wrong.