mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 11:37:27 +01:00
Add PR labels based on files changed (#1127)
* Add PR labels based on files changed * Remove platform code
This commit is contained in:
parent
c52cb7bbad
commit
c296b4c348
24
.github/workflows/pr-labels.yaml
vendored
Normal file
24
.github/workflows/pr-labels.yaml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
name: PR labels
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
|
||||
jobs:
|
||||
pr-label:
|
||||
runs-on: ubuntu-latest
|
||||
name: PR label
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- id: pr_labels
|
||||
run: script/pr-labels ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
|
||||
- uses: octokit/request-action@v2.0.7
|
||||
if: ${{ steps.pr_labels.outputs.labels != '[""]' }}
|
||||
with:
|
||||
route: POST /repos/:repository/issues/:number/labels
|
||||
number: ${{ github.event.number }}
|
||||
repository: ${{ github.repository }}
|
||||
labels: ${{ steps.pr_labels.outputs.labels }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
29
script/pr-labels
Executable file
29
script/pr-labels
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
components=()
|
||||
for c_diff in $(git diff ${1}..${2} --name-only esphome/components); do
|
||||
base=${c_diff#esphome/components/}
|
||||
component=`dirname ${base}`
|
||||
|
||||
if [[ "${component}" == "." ]]; then
|
||||
component=${platform}
|
||||
fi
|
||||
|
||||
if [[ ! "${components[@]}" =~ "${component}" ]]; then
|
||||
components+=($component)
|
||||
fi
|
||||
done
|
||||
|
||||
labels=()
|
||||
|
||||
echo "Components:"
|
||||
for component in ${components[@]}; do
|
||||
echo " ${component}"
|
||||
labels+=("component: $component")
|
||||
done
|
||||
|
||||
echo "Labels: ${labels[@]}"
|
||||
|
||||
output=$(printf '%s\n' "${labels[@]}" | jq -R . | jq -c -s .)
|
||||
|
||||
echo "::set-output name=labels::${output}"
|
Loading…
Reference in New Issue
Block a user