-
-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (74 loc) · 2.35 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: CI
# yamllint disable-line rule:truthy
on:
push:
branches:
- main
pull_request: ~
jobs:
code-style:
name: Code style
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Run prettier
uses: creyD/[email protected]
with:
prettier_options: --check .
- name: Run yamllint
uses: frenck/action-yamllint@v1
list-configurations:
name: Prepare matrix to build all configurations
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set matrix values
id: set-matrix
run: echo "matrix=$(grep -l "esphome:" *.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
build:
name: Building ${{ matrix.configuration }}
runs-on: ubuntu-latest
needs:
- list-configurations
- code-style
strategy:
fail-fast: false
matrix:
configuration: ${{ fromJson(needs.list-configurations.outputs.matrix) }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Mock secrets
uses: golles/mock-yaml-secrets-action@v1
with:
configFile: ".github/workflows/mock-secrets-config.json"
- name: Build ESPHome firmware
uses: esphome/build-action@v4
id: esphome-build
with:
yaml-file: ${{ matrix.configuration }}
- name: Prepare firmware for upload
run: |
mkdir output
mv "${{ steps.esphome-build.outputs.name }}" output/
- name: Upload firmware
uses: actions/upload-artifact@v4
with:
name: ${{ steps.esphome-build.outputs.name }}
path: output
results:
# see https://github.community/t/status-check-for-a-matrix-jobs/127354/7
name: Final results
runs-on: ubuntu-latest
if: ${{ always() }}
needs: build
steps:
- name: Check all job status
# see https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context
# see https://stackoverflow.com/a/67532120/4907315
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}
run: exit 1