-
-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bot): auto-label config PRs (#1534)
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: 'Z-Wave Bot: Organize PRs' | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize, reopened] | ||
|
||
jobs: | ||
# Label configuration updates with "config" | ||
config-label: | ||
runs-on: [ubuntu-latest] | ||
steps: | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
fetch-depth: 0 # Fetch the history, or this action won't work | ||
|
||
- name: Detect changes (git) | ||
id: check-changes | ||
run: | | ||
# =============================== | ||
# Detect changes using git | ||
# =============================== | ||
# Check if there were any config file changes | ||
if ! git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -E "packages\/config\/config\/(.*\/)?.+\.json" ; then | ||
echo "🔸 No config file changes" | ||
echo "::set-output name=changes::no" | ||
exit 0 | ||
fi | ||
# Check if there were changes except config files and .gitignore | ||
if git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -E -v "packages\/config\/config\/(.*\/)?.+\.json" | grep -v ".gitignore" ; then | ||
echo "❌ Found non-config changes, aborting..." | ||
echo "::set-output name=changes::other" | ||
exit 0 | ||
else | ||
echo "✔ Changes are limited to config files" | ||
echo "::set-output name=changes::config" | ||
fi | ||
- uses: actions/github-script@v3 | ||
if: steps.check-changes.outputs.changes == 'config' | ||
with: | ||
github-token: ${{secrets.BOT_TOKEN}} | ||
script: | | ||
const options = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}; | ||
await github.issues.addLabels({ | ||
...options, | ||
issue_number: context.payload.pull_request.number, | ||
labels: ['config ⚙'] | ||
}); | ||