-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (98 loc) · 3.1 KB
/
Copy pathbuilder.yaml
File metadata and controls
107 lines (98 loc) · 3.1 KB
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
102
103
104
105
106
107
name: Builder
env:
MONITORED_FILES: "config.json config.yaml config.yml Dockerfile rootfs"
on:
workflow_dispatch:
inputs:
app:
description: Optional app directory to build
required: false
type: string
default: ""
publish:
description: Publish images and the multi-architecture manifest
required: true
type: boolean
default: true
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
discover:
name: Discover changed apps
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.filter.outputs.changed }}
apps: ${{ steps.filter.outputs.apps }}
steps:
- name: Check out repository
uses: actions/checkout@v7.0.1
- name: Find changed files
id: changed_files
uses: tj-actions/changed-files@v47
- name: Find app directories
id: apps
uses: home-assistant/actions/helpers/find-addons@master
- name: Select apps to build
id: filter
shell: bash
env:
ALL_APPS: ${{ steps.apps.outputs.addons }}
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
EVENT_NAME: ${{ github.event_name }}
REQUESTED_APP: ${{ inputs.app || '' }}
run: |
selected=()
if [[ "$EVENT_NAME" == "workflow_dispatch" && -n "$REQUESTED_APP" ]]; then
known_app=false
for app in $ALL_APPS; do
if [[ "$app" == "$REQUESTED_APP" ]]; then
known_app=true
break
fi
done
if [[ "$known_app" != true ]]; then
echo "Unknown app directory: $REQUESTED_APP" >&2
exit 1
fi
selected=("$REQUESTED_APP")
elif [[ "$EVENT_NAME" == "workflow_dispatch" ]] \
|| [[ "$CHANGED_FILES" =~ \.github/workflows/(builder|build-app)\.yaml ]]; then
selected=($ALL_APPS)
else
for app in $ALL_APPS; do
for file in $MONITORED_FILES; do
if [[ "$CHANGED_FILES" =~ (^|[[:space:]])${app}/${file} ]]; then
selected+=("$app")
break
fi
done
done
fi
if (( ${#selected[@]} )); then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "apps=$(jq -nc '$ARGS.positional' --args "${selected[@]}")" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
echo 'apps=[]' >> "$GITHUB_OUTPUT"
fi
build:
name: Build ${{ matrix.app }}
needs: discover
if: needs.discover.outputs.changed == 'true'
permissions:
contents: read
id-token: write
packages: write
strategy:
fail-fast: false
matrix:
app: ${{ fromJSON(needs.discover.outputs.apps) }}
uses: ./.github/workflows/build-app.yaml
with:
app: ${{ matrix.app }}
publish: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish) }}
secrets: inherit