Skip to content

Add optional secrets file #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ on:
required: false
type: string
default: ""
secrets-environment:
description: Environment to use to access secrets
required: false
type: string
default: ""

outputs:
version:
Expand Down Expand Up @@ -72,6 +77,8 @@ jobs:
name: ${{ matrix.file }}
needs: [prepare]
runs-on: ubuntu-latest
environment:
name: ${{ inputs.secrets-environment }}
strategy:
fail-fast: false
max-parallel: 3
Expand All @@ -80,6 +87,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
- name: Configure secrets.yaml file
if: ${{ inputs.secrets-environment != '' }}
id: decode-base64
run: echo "${{ secrets.ESPHOME_SECRETS_YAML }}" | base64 -d > $(dirname ${{ matrix.file }})/secrets.yaml
- name: Replace project version
run: |
sed -i "s/version: dev/version: ${{ needs.prepare.outputs.version }}/g" ${{ matrix.file }}
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,25 @@ This repository contains workflows to be used by other repositories.


See https://github.com/esphome/esphome-project-template for usage of these workflows

## Secrets file

The `secrets.yaml` file can be injected into the build as a GitHub Action secret.

To do so, create a file like something below:

```yaml
wifi_ssid: MyWiFi
wifi_password: mywifipassword

# For more on this, see docs: https://esphome.io/components/api.html#configuration-variables
encryption_key: "QQXcWdXZzCuNT3tTtU33nTiqvxkbR1nWIf4lh6W8MA0="
```

Then base64 encode it and upload it the environment provided with the name `ESPHOME_SECRETS_YAML` and the value base64 encoded.

On macOS, to base64 encode quickly:

```
pbpaste | base64 | pbcopy
```