Skip to content
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

Github workflow to check if examples build #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
45 changes: 45 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build ESPHome firmware

# Controls when the action will run. Triggers the workflow on push
on:
push:
pull_request:
release:

jobs:
setup:
runs-on: ubuntu-latest
outputs:
mymatrix: ${{ steps.dataStep.outputs.myoutput }}
steps:
- name: "Checkout"
uses: actions/checkout@v3
- id: dataStep
run: |
TARGETS=$(ls examples/*.yaml | jq -R -s -c 'split("\n")[:-1]')
echo "myoutput=$(jq -cn --argjson environments $TARGETS '{target: $environments}')" >> $GITHUB_OUTPUT
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run-matrix:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.setup.outputs.mymatrix) }}
steps:
- run: echo ${{matrix.target}}
- name: "Checkout"
uses: actions/checkout@v3
- name: "Patch config to test local component"
run: |
echo "Replace !secrets to some dummy string"
sed -i 's/!secret.*/Dummy123/g' ${{matrix.target}}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to create a secrets file.

Also i think we should make a copy of the config and edit that file? I sort of dislike editing checked in files even if it's temporary.

echo "Use local component for build"
sed -i 's/type: git/type: local/g' ${{matrix.target}}
sed -i 's/url: https:\/\/github.*/path: ..\/components/g' ${{matrix.target}}
sed -i 's/source: github.*/source: ..\/components/g' ${{matrix.target}}
echo "Remove encryption key"
sed -i '/encryption:/,+2d' ${{matrix.target}}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this?

cat ${{matrix.target}}
- name: "Build"
uses: esphome/build-action@v1.8.0
id: esphome-build-esp32
with:
yaml_file: ${{matrix.target}}