From 39178afe47e315c17e4df937bc8f06d6ebb521f2 Mon Sep 17 00:00:00 2001 From: Dan Kiuna Date: Mon, 6 Apr 2026 10:48:34 -0500 Subject: [PATCH] ci: Add new power PR check workflow --- .github/workflows/new-power-check.yml | 76 +++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/new-power-check.yml diff --git a/.github/workflows/new-power-check.yml b/.github/workflows/new-power-check.yml new file mode 100644 index 0000000..02ea2a2 --- /dev/null +++ b/.github/workflows/new-power-check.yml @@ -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 + });