Skip to content

Commit 2fd343d

Browse files
ludeeusclaude
andauthored
Make checks workflow label-driven via run-type output (#8524)
* Make checks workflow label-driven via run-type output Replace the fragile 'removal' detection (which inferred removals from a 'Bad data []' parse-error sentinel) with an explicit, label-driven run-type output on the preflight job: - remove-repositories -> removal - New default repository -> new-repository - renamed-repositories -> renamed - no known label -> unknown Fail the preflight if more than one of these labels is set. Only new-repository PRs run the preflight detection steps and the downstream jobs (except editable). Add the labeled trigger so applying a label re-runs the checks. * Apply suggestion from @ludeeus * Rename run-type output to run_type in checks workflow * Simplify run type detection to a plain if/elif chain * Remove paths guard from checks workflow trigger --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b613fd1 commit 2fd343d

1 file changed

Lines changed: 30 additions & 21 deletions

File tree

.github/workflows/checks.yml

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,10 @@ on:
66
- opened
77
- synchronize
88
- reopened
9+
- labeled
910
- unlabeled
1011
branches:
1112
- master
12-
paths:
13-
- appdaemon
14-
- integration
15-
- plugin
16-
- python_script
17-
- template
18-
- theme
1913

2014
concurrency:
2115
group: checks-${{ github.ref }}
@@ -30,39 +24,54 @@ jobs:
3024
outputs:
3125
repository: ${{ steps.repository.outputs.repository }}
3226
category: ${{ steps.category.outputs.category }}
33-
removal: ${{ steps.removal.outputs.removal }}
27+
run_type: ${{ steps.run_type.outputs.run_type }}
3428
steps:
29+
- name: Determine run type
30+
id: run_type
31+
env:
32+
HAS_REMOVAL: ${{ contains(github.event.pull_request.labels.*.name, 'remove-repositories') }}
33+
HAS_NEW_REPO: ${{ contains(github.event.pull_request.labels.*.name, 'New default repository') }}
34+
HAS_RENAMED: ${{ contains(github.event.pull_request.labels.*.name, 'renamed-repositories') }}
35+
run: |
36+
if [ "$HAS_NEW_REPO" == "true" ]; then
37+
echo "run_type=new-repository" >> $GITHUB_OUTPUT
38+
elif [ "$HAS_RENAMED" == "true" ]; then
39+
echo "run_type=rename" >> $GITHUB_OUTPUT
40+
elif [ "$HAS_REMOVAL" == "true" ]; then
41+
echo "run_type=removal" >> $GITHUB_OUTPUT
42+
else
43+
echo "run_type=unknown" >> $GITHUB_OUTPUT
44+
fi
45+
3546
- name: Check out repository
47+
if: steps.run_type.outputs.run_type == 'new-repository'
3648
uses: actions/checkout@v6.0.2
3749

3850
- name: Set up Python
51+
if: steps.run_type.outputs.run_type == 'new-repository'
3952
uses: actions/setup-python@v6.2.0
4053
with:
4154
python-version-file: ".python-version"
4255

4356
- name: Clone origin
57+
if: steps.run_type.outputs.run_type == 'new-repository'
4458
run: git clone --depth 1 https://github.com/hacs/default /tmp/repositories/default
4559

4660
- name: Set repository
4761
id: repository
62+
if: steps.run_type.outputs.run_type == 'new-repository'
4863
run: echo "repository=$(python3 -m scripts.changed.repo)" >> $GITHUB_OUTPUT
4964

5065
- name: Set category
5166
id: category
67+
if: steps.run_type.outputs.run_type == 'new-repository'
5268
run: echo "category=$(python3 -m scripts.changed.category)" >> $GITHUB_OUTPUT
5369

54-
- name: Check removal
55-
id: removal
56-
run: |
57-
if [ "${{ steps.repository.outputs.repository }}" == "Bad data []" ]; then
58-
echo "removal=true" >> $GITHUB_OUTPUT
59-
fi
60-
6170
owner:
6271
runs-on: ubuntu-latest
6372
name: Owner
6473
needs: preflight
65-
if: needs.preflight.outputs.removal != 'true'
74+
if: needs.preflight.outputs.run_type == 'new-repository'
6675
steps:
6776
- name: Check out repository
6877
uses: actions/checkout@v6.0.2
@@ -108,7 +117,7 @@ jobs:
108117
runs-on: ubuntu-latest
109118
name: Releases
110119
needs: preflight
111-
if: needs.preflight.outputs.removal != 'true'
120+
if: needs.preflight.outputs.run_type == 'new-repository'
112121
steps:
113122
- name: Check out repository
114123
uses: actions/checkout@v6.0.2
@@ -133,7 +142,7 @@ jobs:
133142
runs-on: ubuntu-latest
134143
name: Removed repository
135144
needs: preflight
136-
if: needs.preflight.outputs.removal != 'true'
145+
if: needs.preflight.outputs.run_type == 'new-repository'
137146
steps:
138147
- name: Check out repository
139148
uses: actions/checkout@v6.0.2
@@ -157,7 +166,7 @@ jobs:
157166
runs-on: ubuntu-latest
158167
name: Existing repository
159168
needs: preflight
160-
if: needs.preflight.outputs.removal != 'true'
169+
if: needs.preflight.outputs.run_type == 'new-repository'
161170
steps:
162171
- name: Check out repository
163172
uses: actions/checkout@v6.0.2
@@ -181,7 +190,7 @@ jobs:
181190
runs-on: ubuntu-latest
182191
name: Hassfest
183192
needs: preflight
184-
if: needs.preflight.outputs.category == 'integration' && needs.preflight.outputs.removal != 'true'
193+
if: needs.preflight.outputs.category == 'integration' && needs.preflight.outputs.run_type == 'new-repository'
185194
steps:
186195
- name: Check out repository
187196
uses: actions/checkout@v6.0.2
@@ -202,7 +211,7 @@ jobs:
202211
runs-on: ubuntu-latest
203212
name: HACS action
204213
needs: preflight
205-
if: needs.preflight.outputs.removal != 'true'
214+
if: needs.preflight.outputs.run_type == 'new-repository'
206215
steps:
207216
- name: HACS action
208217
uses: hacs/action@main

0 commit comments

Comments
 (0)