-
Notifications
You must be signed in to change notification settings - Fork 26
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
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}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this somewhat hard tro grasp: this looks a bit cleaner: https://code.dblock.org/2021/09/03/generating-task-matrix-by-looping-over-repo-files-with-github-actions.html