Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/new-power-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: New Power PR Check

on:
pull_request:
types: [opened]

permissions:
pull-requests: write
contents: read

jobs:
check-new-power:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Detect new power folders
id: detect
run: |
SKIP_DIRS=".git .github .kiro checkout"

# Get folders that exist on the base branch
BASE_FOLDERS=$(git ls-tree --name-only -d "origin/${{ github.event.pull_request.base.ref }}" 2>/dev/null || true)

# Get top-level folders touched in this PR
PR_FOLDERS=$(git diff --name-only "origin/${{ github.event.pull_request.base.ref }}...HEAD" \
| cut -d'/' -f1 \
| sort -u)

NEW_FOLDERS=""
for folder in $PR_FOLDERS; do
# Skip files (no directory in diff)
[ -d "$folder" ] || continue

# Skip meta directories
skip=false
for s in $SKIP_DIRS; do
[ "$folder" = "$s" ] && skip=true && break
done
$skip && continue

# Check if folder existed on base branch
if ! echo "$BASE_FOLDERS" | grep -qx "$folder"; then
NEW_FOLDERS="$NEW_FOLDERS $folder"
fi
done

NEW_FOLDERS=$(echo "$NEW_FOLDERS" | xargs)
echo "new_folders=$NEW_FOLDERS" >> "$GITHUB_OUTPUT"
if [ -n "$NEW_FOLDERS" ]; then
echo "has_new=true" >> "$GITHUB_OUTPUT"
else
echo "has_new=false" >> "$GITHUB_OUTPUT"
fi

- name: Comment on PR
if: steps.detect.outputs.has_new == 'true'
uses: actions/github-script@v7
with:
script: |
const user = context.payload.pull_request.user.login;
const body = [
`Hi @${user}, thank you for your contribution!`,
'',
'Please note that if you haven\'t already, you would also need to submit your power officially at [kiro.dev/powers/submit](https://kiro.dev/powers/submit) so it can be reviewed for listing in the Kiro powers registry.'
].join('\n');

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
Loading