diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..f636f18 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,10 @@ +FROM ghcr.io/home-assistant/devcontainer:addons + +RUN \ + apt-get update \ + && apt-get install -y --no-install-recommends \ + python3-pip + +COPY script/requirements.txt / + +RUN pip install -r /requirements.txt diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..2ea3341 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,36 @@ +{ + "name": "ESPHome Home Assistant add-on devcontainer", + "image": "ghcr.io/esphome/devcontainer:addons", + "appPort": [ + "7123:8123", + "7357:4357" + ], + "postStartCommand": "bash devcontainer_bootstrap", + "runArgs": [ + "-e", + "GIT_EDITOR=code --wait", + "--privileged" + ], + "containerEnv": { + "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" + }, + "extensions": [ + "timonwong.shellcheck", + "esbenp.prettier-vscode" + ], + "mounts": [ + "type=volume,target=/var/lib/docker" + ], + "settings": { + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/usr/bin/zsh" + } + }, + "terminal.integrated.defaultProfile.linux": "zsh", + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true + } +} diff --git a/.github/workflows/devcontainer-build.yaml b/.github/workflows/devcontainer-build.yaml new file mode 100644 index 0000000..76ec9f1 --- /dev/null +++ b/.github/workflows/devcontainer-build.yaml @@ -0,0 +1,41 @@ +name: Build devcontainer image + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - .devcontainer/** + schedule: + - cron: '0 0 1 * *' + pull_request: + branches: + - main + paths: + - .devcontainer/** + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.1.0 + - name: Log in to the GitHub container registry + uses: docker/login-action@v2.1.0 + if: github.event_name != 'pull_request' + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2.1.0 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2.2.1 + - name: Build and Push + uses: docker/build-push-action@v3.2.0 + with: + context: . + file: .devcontainer/Dockerfile + tags: ghcr.io/${{ github.repository_owner }}/devcontainer:addons + push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64 diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..cb4e05c --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,19 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Start Home Assistant", + "type": "shell", + "command": "supervisor_run", + "group": { + "kind": "test", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + } + ] +}