Skip to content

Commit

Permalink
feat(bot): auto-label config PRs (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Jan 30, 2021
1 parent 1626490 commit d7d4848
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/zwave-js-bot_pulls.yml
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 ⚙']
});

0 comments on commit d7d4848

Please sign in to comment.