forked from esphome/build-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
101 lines (97 loc) · 3.05 KB
/
action.yml
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: ESPHome Builder
description: Builds ESPHome binaries
inputs:
yaml_file:
description: YAML file to use
required: true
version:
description: Version of ESPHome to build
required: false
default: latest
platform:
description: Platform (OS/Arch) to use
required: false
default: linux/amd64
cache:
description: Cache build directory
required: false
default: false
release_summary:
description: Release summary
required: false
default: ""
release_url:
description: Release URL
required: false
default: ""
outputs:
name:
description: Name of device extracted from configuration with the platform appended
value: ${{ steps.build-step.outputs.name }}
version:
description: ESPHome version
value: ${{ steps.build-step.outputs.esphome-version }}
original_name:
description: Original name of device extracted from configuration
value: ${{ steps.build-step.outputs.original_name }}
runs:
using: composite
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
with:
platforms: ${{ inputs.platform }}
- name: Build ESPHome image
uses: docker/build-push-action@v5.3.0
with:
context: ${{ github.action_path }}
load: true
tags: esphome:${{ inputs.version }}
build-args: VERSION=${{ inputs.version }}
platforms: ${{ inputs.platform }}
- if: ${{ inputs.cache == 'true' }}
id: data-dir
shell: bash
run: |
data_dir=$(dirname ${{ inputs.yaml_file }})/.esphome
echo "data_dir=$data_dir" >> $GITHUB_OUTPUT
- if: ${{ inputs.cache == 'true' }}
name: Cache platformio directory
uses: actions/cache@v4.0.2
with:
path: ~/.platformio
key: ${{ runner.os }}-esphome-${{ inputs.yaml_file }}-${{ inputs.version }}-platformio
- if: ${{ inputs.cache == 'true' }}
name: Cache build directory
uses: actions/cache@v4.0.2
with:
path: ${{ steps.data-dir.outputs.data_dir }}/build
key: ${{ runner.os }}-esphome-${{ inputs.yaml_file }}-${{ inputs.version }}-build
save-always: true
- if: ${{ inputs.cache == 'true' }}
name: Cache storage directory
uses: actions/cache@v4.0.2
with:
path: ${{ steps.data-dir.outputs.data_dir }}/storage
key: ${{ runner.os }}-esphome-${{ inputs.yaml_file }}-${{ inputs.version }}-storage
save-always: true
- name: Run container
shell: bash
id: build-step
run: |-
docker run --rm \
--platform ${{ inputs.platform }} \
--workdir /github/workspace \
-v "$(pwd)":"/github/workspace" -v "$HOME:$HOME" \
--user $(id -u):$(id -g) \
-e HOME \
esphome:${{ inputs.version }} \
${{ inputs.yaml_file }} \
--release-summary "${{ inputs.release_summary }}" \
--release-url "${{ inputs.release_url }}" \
--outputs-file "$GITHUB_OUTPUT"
branding:
icon: "archive"
color: "white"