diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..1679a9e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @frenck diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..7f95bd4 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +--- +github: frenck +patreon: frenck +custom: https://frenck.dev/donate/ diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..45dd97a --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,8 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily + time: "06:00" diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..42f0eb5 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,87 @@ +--- +- name: "breaking-change" + color: ee0701 + description: "A breaking change for existing users." +- name: "bugfix" + color: ee0701 + description: + "Inconsistencies or issues which will cause a problem for users or + implementors." +- name: "documentation" + color: 0052cc + description: "Solely about the documentation of the project." +- name: "enhancement" + color: 1d76db + description: "Enhancement of the code, not introducing new features." +- name: "refactor" + color: 1d76db + description: "Improvement of existing code, not introducing new features." +- name: "performance" + color: 1d76db + description: "Improving performance, not introducing new features." +- name: "new-feature" + color: 0e8a16 + description: "New features or options." +- name: "maintenance" + color: 2af79e + description: "Generic maintenance tasks." +- name: "chore" + color: 2af79e + description: "Generic chore." +- name: "ci" + color: 1d76db + description: "Work that improves the continue integration." + +- name: "in-progress" + color: fbca04 + description: "Issue is currently being resolved by a developer." +- name: "stale" + color: fef2c0 + description: + "There has not been activity on this issue or PR for quite some time." +- name: "no-stale" + color: fef2c0 + description: "This issue or PR is exempted from the stable bot." + +- name: "security" + color: ee0701 + description: "Marks a security issue that needs to be resolved asap." +- name: "incomplete" + color: fef2c0 + description: "Marks a PR or issue that is missing information." +- name: "invalid" + color: fef2c0 + description: "Marks a PR or issue that is missing information." + +- name: "beginner-friendly" + color: 0e8a16 + description: + "Good first issue for people wanting to contribute to the project." +- name: "help-wanted" + color: 0e8a16 + description: + "We need some extra helping hands or expertise in order to resolve this." + +- name: "hacktoberfest" + description: "Issues/PRs are participating in the Hacktoberfest." + color: fbca04 +- name: "hacktoberfest-accepted" + description: "Issues/PRs are participating in the Hacktoberfest." + color: fbca04 + +- name: "priority-critical" + color: ee0701 + description: + "This should be dealt with ASAP. Not fixing this issue would be a serious + error." +- name: "priority-high" + color: b60205 + description: + "After critical issues are fixed, these should be dealt with before any + further issues." +- name: "priority-medium" + color: 0e8a16 + description: "This issue may be useful, and needs some attention." +- name: "priority-low" + color: e4ea8a + description: "Nice addition, maybe... someday..." diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..c985432 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,57 @@ +--- +name-template: "v$RESOLVED_VERSION" +tag-template: "v$RESOLVED_VERSION" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +sort-direction: ascending + +categories: + - title: "🚨 Breaking changes" + labels: + - "breaking-change" + - title: "✨ New features" + labels: + - "new-feature" + - title: "πŸ› Bug fixes" + labels: + - "bugfix" + - title: "πŸš€ Enhancements" + labels: + - "enhancement" + - "refactor" + - "performance" + - title: "🧰 Maintenance" + labels: + - "chore" + - "ci" + - title: "πŸ“š Documentation" + labels: + - "documentation" + - title: "⬆️ Dependency updates" + labels: + - "dependencies" + +version-resolver: + major: + labels: + - "major" + - "breaking-change" + minor: + labels: + - "minor" + - "new-feature" + patch: + labels: + - "bugfix" + - "chore" + - "ci" + - "dependencies" + - "documentation" + - "enhancement" + - "performance" + - "refactor" + default: patch + +template: | + ## What’s changed + + $CHANGES diff --git a/.github/workflows/labels.yaml b/.github/workflows/labels.yaml new file mode 100644 index 0000000..654932d --- /dev/null +++ b/.github/workflows/labels.yaml @@ -0,0 +1,23 @@ +--- +name: Sync labels + +# yamllint disable-line rule:truthy +on: + push: + branches: + - main + paths: + - .github/labels.yml + workflow_dispatch: + +jobs: + labels: + name: ♻️ Sync labels + runs-on: ubuntu-latest + steps: + - name: ‡️ Check out code from GitHub + uses: actions/checkout@v2.3.4 + - name: πŸš€ Run Label Syncer + uses: micnncim/action-label-syncer@v1.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..e5c494e --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,39 @@ +--- +name: Lint + +# yamllint disable-line rule:truthy +on: [push, pull_request] + +jobs: + build: + name: 🧹 yamllint + runs-on: ubuntu-latest + steps: + - name: ‡️ Check out code from GitHub + uses: actions/checkout@v2 + - name: πŸš€ Run yamllint + uses: frenck/action-yamllint@v1.0.1 + + json: + name: 🧹 JSON Lint + runs-on: ubuntu-latest + steps: + - name: ‡️ Check out code from GitHub + uses: actions/checkout@v2.3.4 + - name: πŸš€ Run JQ + run: | + shopt -s globstar + cat **/*.json | jq '.' + + prettier: + name: 🧹 Prettier + runs-on: ubuntu-latest + steps: + - name: ‡️ Check out code from GitHub + uses: actions/checkout@v2.3.4 + - name: πŸš€ Run Prettier + uses: creyD/prettier_action@v3.3 + with: + prettier_options: --write **/*.{json,js,md,yaml} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lock.yaml b/.github/workflows/lock.yaml new file mode 100644 index 0000000..ff147a2 --- /dev/null +++ b/.github/workflows/lock.yaml @@ -0,0 +1,21 @@ +--- +name: Lock + +# yamllint disable-line rule:truthy +on: + schedule: + - cron: "0 9 * * *" + workflow_dispatch: + +jobs: + lock: + name: πŸ”’ Lock closed issues and PRs + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v2.0.3 + with: + github-token: ${{ github.token }} + issue-lock-inactive-days: "30" + issue-lock-reason: "" + pr-lock-inactive-days: "1" + pr-lock-reason: "" diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 0000000..25f9856 --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -0,0 +1,18 @@ +--- +name: Release Drafter + +# yamllint disable-line rule:truthy +on: + push: + branches: + - main + +jobs: + update_release_draft: + name: ✏️ Draft release + runs-on: ubuntu-latest + steps: + - name: πŸš€ Run Release Drafter + uses: release-drafter/release-drafter@v5.13.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml new file mode 100644 index 0000000..02e1d77 --- /dev/null +++ b/.github/workflows/stale.yaml @@ -0,0 +1,40 @@ +--- +name: Stale + +# yamllint disable-line rule:truthy +on: + schedule: + - cron: "0 8 * * *" + workflow_dispatch: + +jobs: + stale: + name: 🧹 Clean up stale issues and PRs + runs-on: ubuntu-latest + steps: + - name: πŸš€ Run stale + uses: actions/stale@v3.0.14 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-stale: 30 + days-before-close: 7 + remove-stale-when-updated: true + stale-issue-label: "stale" + exempt-issue-labels: "no-stale,help-wanted" + stale-issue-message: > + There hasn't been any activity on this issue recently, so we clean + up some of the older and inactive issues. + + Please make sure to update to the latest version and check if that + solves the issue. Let us know if that works for you by leaving a + comment πŸ‘ + + This issue has now been marked as stale and will be closed if no + further activity occurs. Thanks! + stale-pr-label: "stale" + exempt-pr-labels: "no-stale" + stale-pr-message: > + There hasn't been any activity on this pull request recently. This + pull request has been automatically marked as stale because of that + and will be closed if no further activity occurs within 7 days. + Thank you for your contributions. diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..90c552f --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,15 @@ +name: Test +on: [push, pull_request] +jobs: + build: + name: Home Assistant Core Configuration Check + runs-on: ubuntu-latest + steps: + - name: ‡️ Check out code from GitHub + uses: actions/checkout@v2 + - name: πŸš€ Run Home Assistant Configuration Check + uses: frenck/action-home-assistant@v1 + with: + path: "./test" + secrets: fakesecrets.yaml + version: stable diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..8b146f4 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,133 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or + advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email + address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +frenck@frenck.dev. + +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][mozilla coc]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][faq]. Translations are available +at [https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html +[mozilla coc]: https://github.com/mozilla/diversity +[faq]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3f2e9cf --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Contributing + +When contributing to this repository, please first discuss the change you wish +to make via issue, email, or any other method with the owners of this repository +before making a change. + +Please note we have a code of conduct, please follow it in all your interactions +with the project. + +## Issues and feature requests + +You've found a bug in the source code, a mistake in the documentation or maybe +you'd like a new feature? You can help us by submitting an issue to our +[GitHub Repository][github]. Before you create an issue, make sure you search +the archive, maybe your question was already answered. + +Even better: You could submit a pull request with a fix / new feature! + +## Pull request process + +1. Search our repository for open or closed [pull requests][prs] that relates + to your submission. You don't want to duplicate effort. + +1. You may merge the pull request in once you have the sign-off of two other + developers, or if you do not have permission to do that, you may request + the second reviewer to merge it for you. + +[github]: https://github.com/frenck/action-home-assistant/issues +[prs]: https://github.com/frenck/action-home-assistant/pulls diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..d6410c3 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2021 Franck Nijhof + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2f808a7 --- /dev/null +++ b/README.md @@ -0,0 +1,205 @@ +# πŸš€ Frenck's Github Action: Home Assistant Core Configuration Check + +[![GitHub Release][releases-shield]][releases] +![Project Stage][project-stage-shield] +![Project Maintenance][maintenance-shield] +[![License][license-shield]](LICENSE.md) + +[![Sponsor Frenck via GitHub Sponsors][github-sponsors-shield]][github-sponsors] + +πŸš€ Frenck's GitHub Action for running a Home Assistant Core configuration check. + +## About + +This GitHub action runs a Home Assistant Core configuration check against your +repository. + +Please note; that this Action is useable for all Home Assistant installation +types, and thus **NOT** limited to Home Assistant Core users. It also works +if you are running Home Assistant Container, Supervised or OS. + +## Usage + +```yaml +name: Check +on: [push, pull_request] +jobs: + home-assistant: + name: Home Assistant Core Configuration Check + runs-on: ubuntu-latest + steps: + - name: ‡️ Check out configuration from GitHub + uses: actions/checkout@v2 + - name: πŸš€ Run Home Assistant Configuration Check + uses: frenck/action-home-assistant@v1 + with: + path: "./config" + secrets: fakesecrets.yaml + version: stable +``` + +## Arguments + +| Input | Description | Usage | +| :---------: | :-----------------------------------------------------------------: | :----------: | +| `path` | Path to the folder containing the Home Assistant Core configuration. | _Optional_ | +| `secrets` | Alternative secrets file to use, e.g., "fakesecrets.yaml". | _Optional_ | +| `version` | Version to use; dev/beta/stable or a specific version number. | _Optional_ | + +### Specific configuration folder + +By default, this GitHub Action will use the root folder as the Home Assistant +Core configuration folder. If you store your Home Assistant configuration in a +subfolder, the `path` argument can be used to inform the Action about that. + +For example, if you configuration is in the `config` folder: + +```yaml +- name: πŸš€ Run Home Assistant Core Configuration Check + uses: frenck/action-home-assistant@v1 + with: + path: "./config" +``` + +### Using a fake secrets file + +Of course, you don't want to commit your secrets file. However, without a +secrets file, your configuration check will most likely not pass. + +This GitHub Action offers a way around that, but using a fake secrets file. + +To use this, add a fake secrets file to your repository (e.g., +`fakesecrets.yaml`) and make sure the content is the same as your real +`secrets.yaml` (with, of course, fake credentials/data). The GitHub Action +will use this file during checking your configuration. + +For example, if you fake secrets file is `fakesecrets.yaml`: + +```yaml +- name: πŸš€ Run Home Assistant Core Configuration Check + uses: frenck/action-home-assistant@v1 + with: + secrets: "fakesecrets.yaml" +``` + +### Running against a specific version + +This GitHub Action allows you to specify a specific version to run +your Home Assistant Core configuration against. However, by default, the +integration will try to find the `.HA_VERSION` file in your configuration +folder. + +If the `.HA_VERSION` file is found, the version in that file is used. If +the `.HA_VERSION` file is not found; the Action will use the latest stable +version of Home Assistant to test your configuration with. + +However, you can specify/override any version you like to check against, +for example, check with Home Assistant Core `2021.1.0`: + +```yaml +- name: πŸš€ Run Home Assistant Core Configuration Check + uses: frenck/action-home-assistant@v1 + with: + version: "2021.1.0" +``` + +Alternatively, you can also use `stable`, `beta` or `dev` to run against +latest versions of those stability channels. + +```yaml +- name: πŸš€ Run Home Assistant Core Configuration Check + uses: frenck/action-home-assistant@v1 + with: + version: beta +``` + +## More extensive example + +A more extensive example, that runs your configuration against the latest +development, beta and stable versions: + +```yaml +name: Check +on: [push, pull_request] +jobs: + home-assistant: + name: "Home Assistant Core ${{ matrix.version }} Configuration Check" + runs-on: ubuntu-latest + strategy: + matrix: + version: ["stable", "beta", "dev"] + steps: + - name: ‡️ Check out configuration from GitHub + uses: actions/checkout@v2 + - name: πŸš€ Run Home Assistant Configuration Check + uses: frenck/action-home-assistant@v1 + with: + path: "./config" + secrets: fakesecrets.yaml + version: "${{ matrix.version }}" +``` + +## Changelog & Releases + +This repository keeps a change log using [GitHub's releases][releases] +functionality. + +Releases are based on [Semantic Versioning][semver], and use the format +of `MAJOR.MINOR.PATCH`. In a nutshell, the version will be incremented +based on the following: + +- `MAJOR`: Incompatible or major changes. +- `MINOR`: Backwards-compatible new features and enhancements. +- `PATCH`: Backwards-compatible bugfixes and package updates. + +## Contributing + +This is an active open-source project. We are always open to people who want to +use the code or contribute to it. + +We've set up a separate document for our +[contribution guidelines](CONTRIBUTING.md). + +Thank you for being involved! :heart_eyes: + +## Authors & contributors + +The original setup of this repository is by [Franck Nijhof][frenck]. + +For a full list of all authors and contributors, +check [the contributor's page][contributors]. + +## License + +MIT License + +Copyright (c) 2021 Franck Nijhof + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +[contributors]: https://github.com/frenck/action-home-assistant/graphs/contributors +[frenck]: https://github.com/frenck +[github-sponsors-shield]: https://frenck.dev/wp-content/uploads/2019/12/github_sponsor.png +[github-sponsors]: https://github.com/sponsors/frenck +[license-shield]: https://img.shields.io/github/license/frenck/action-home-assistant.svg +[maintenance-shield]: https://img.shields.io/maintenance/yes/2021.svg +[project-stage-shield]: https://img.shields.io/badge/project%20stage-production%20ready-brightgreen.svg +[releases-shield]: https://img.shields.io/github/release/frenck/action-home-assistant.svg +[releases]: https://github.com/frenck/action-home-assistant/releases +[semver]: http://semver.org/spec/v2.0.0.html diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..75bb9f1 --- /dev/null +++ b/action.yaml @@ -0,0 +1,104 @@ +--- +name: "Frenck's Home Assistant Core Configuration Check" +description: + πŸš€ Frenck's GitHub Action for running a Home Assistant config check. +author: frenck + +branding: + color: red + icon: thumbs-up + +inputs: + path: + description: Path to the folder containing the Home Assistant configuration + default: "." + required: false + secrets: + description: Alternative secrets file to use + required: false + version: + description: Version to use; dev/beta/stable or a specific version number + required: false + +runs: + using: "composite" + steps: + - name: πŸ— Check if the configuration is actually there + id: check + shell: bash + run: | + path="${{ inputs.path }}" + path="${path%/}" + if [[ -d "${path}" ]]; then + echo "::error ::Could not find specified configuration path: ${path}" + exit 1 + fi + + if [[ -f "${path}/configuration.yaml" ]]; then + echo "::error ::Could not find configuration.yaml file in: ${path}" + exit 1 + fi + + echo "::set-output name=path::${path}" + + - name: πŸ— Ensure secrets are in place + shell: bash + run: | + if [[ -z "${{ inputs.secrets }}" ]]; then + exit 0 + fi + + secrets="${{ inputs.secrets }}" + secrets="${secrets%/}" + + if [[ -d "${secrets}" ]] && [[ -f "${secrets}/secrets.yaml" ]]; + then + secrets="${secrets}/secrets.yaml" + elif [[ -d "${{ steps.check.outputs.path }}/${secrets}" ]] && \ + [[ -f "${{ steps.check.outputs.path }}/${secrets}/secrets.yaml" ]]; + then + secrets="${{ steps.check.outputs.path }}/${secrets}/secrets.yaml" + elif [[ -f "${{ steps.check.outputs.path }}/${secrets}" ]]; + then + secrets="${{ steps.check.outputs.path }}/${secrets}" + elif [[ ! -f "${secrets}" ]]; + then + echo "::error ::Could not find specified secrets file: ${{ inputs.secrets }}" + exit 1 + fi + + cp "${secrets}" "${{ steps.check.outputs.path }}/secrets.yaml" + + - name: πŸ— Determine & download requested Home Assistant version + shell: bash + id: version + run: | + version="${{ inputs.version }}" + if [[ -z "${version}" ]]; then + if [[ -f "${{ steps.check.outputs.path }}/.HA_VERSION" ]]; then + version=$(<"${{ steps.check.outputs.path }}/.HA_VERSION") + else + echo "::warning ::No specific version found or specified;"\ + "Using 'stable' instead. Specify the version in the GitHub"\ + "Action or ensure the '.HA_VERSION' file is in your repository." + version="stable" + fi + fi + echo "::set-output name=version::${version}" + + docker pull "homeassistant/home-assistant:${{ version }}" + + - name: πŸš€ Run Home Assistant Configuration Check + shell: bash + run: | + docker run --rm \ + "homeassistant/home-assistant:${{ steps.version.outputs.version }}" \ + python -m homeassistant --version + + docker run --rm \ + -v $(pwd):/github/workspace \ + --workdir /github/workspace \ + "homeassistant/home-assistant:${{ steps.version.outputs.version }}" \ + python -m homeassistant \ + --config "${{ steps.check.outputs.path }}" \ + --script check_config diff --git a/test/automations.yaml b/test/automations.yaml new file mode 100644 index 0000000..c79169c --- /dev/null +++ b/test/automations.yaml @@ -0,0 +1,3 @@ +--- +# Empty, which is fine for this example +[] diff --git a/test/configuration.yaml b/test/configuration.yaml new file mode 100644 index 0000000..3e39f09 --- /dev/null +++ b/test/configuration.yaml @@ -0,0 +1,18 @@ +--- +# Configure a default setup of Home Assistant (frontend, api, etc) +default_config: + +# Automations to test an include +automation: !include automations.yaml + +# Text to speech +tts: + - platform: google_translate + +# Demo integration +demo: + +# A sensor, useless, but ensures the fake secrets are loaded +sensor: + - platform: otp + token: !secret frenck diff --git a/test/fakesecrets.yaml b/test/fakesecrets.yaml new file mode 100644 index 0000000..5247e17 --- /dev/null +++ b/test/fakesecrets.yaml @@ -0,0 +1,2 @@ +--- +frenck: SuperSecretPassword!123 diff --git a/test/secrets.yaml b/test/secrets.yaml new file mode 100644 index 0000000..27c4085 --- /dev/null +++ b/test/secrets.yaml @@ -0,0 +1,3 @@ +--- +# This secrets file should be overwritten by the fake secret file. +some_password: welcome