Skip to content
Merged
Show file tree
Hide file tree
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
79 changes: 22 additions & 57 deletions pr-impact-analysis/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# PR Impact Analysis

A GitHub Action that automatically analyzes PR code changes via LLM, generates impact assessment and test recommendations, then creates a Jira issue assigned to QA.
A GitHub Action that analyzes PR code changes and creates Jira QA issues. All analysis logic runs on a Cloudflare Worker — this action is a thin client that collects PR data and delegates.

## How It Works

```
PR merged → Fetch diff → LLM analysis → Create Jira issueAssign to QA
PR merged → Fetch diff → POST to Worker → Worker returns resultSet outputs
```

1. Fetches PR metadata and diff via GitHub API
2. Sends diff to LLM (OpenAI-compatible API) for impact analysis
3. Creates a Jira issue with structured test checklist and risk assessment
2. Sends data to a Cloudflare Worker which handles:
- OK-XXXX Jira key detection (skip if already linked)
- GitHub → Jira user mapping + dedup search
- LLM impact analysis with duplicate detection
- Jira issue creation (if needed)

## Project Structure

```
pr-impact-analysis/
├── action.yml # Action metadata (11 inputs, 3 outputs)
├── action.yml # Action metadata (3 inputs, 4 outputs)
├── package.json # Dependencies: @actions/core, @actions/github, axios
├── dist/index.js # Bundled output (ncc)
├── src/
│ ├── index.js # Entry point - orchestrates the flow
│ ├── github.js # GitHub API - fetch PR info & diff with truncation
│ ├── analyzer.js # LLM API - build prompt, parse JSON response
│ └── jira.js # Jira API - create issue with ADF formatting
│ ├── index.js # Thin client: collect PR data → POST to Worker → set outputs
│ └── github.js # GitHub API: fetch PR info & diff with truncation
└── yarn.lock
```

Expand All @@ -43,63 +44,27 @@ jobs:
uses: OneKeyHQ/actions/pr-impact-analysis@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
llm-api-key: ${{ secrets.PIA_DEEPSEEK_API_KEY }}
jira-base-url: ${{ secrets.PIA_JIRA_BASE_URL }}
jira-email: ${{ secrets.PIA_JIRA_EMAIL }}
jira-api-token: ${{ secrets.PIA_JIRA_API_TOKEN }}
jira-project-key: 'QA'
jira-assignee-id: '<jira-account-id>'
worker-url: ${{ secrets.PR_ANALYSIS_WORKER_URL }}
worker-secret: ${{ secrets.PR_ANALYSIS_WORKER_SECRET }}
```

## Inputs

| Name | Required | Default | Description |
|------|----------|---------|-------------|
| `github-token` | yes | — | GitHub token to fetch PR diff |
| `llm-api-key` | yes | — | LLM API key |
| `llm-api-base-url` | no | `https://api.deepseek.com` | LLM API base URL (OpenAI-compatible) |
| `llm-model` | no | `deepseek-chat` | Model name |
| `jira-base-url` | yes | — | Jira instance URL |
| `jira-email` | yes | — | Jira account email |
| `jira-api-token` | yes | — | Jira API token |
| `jira-project-key` | yes | — | Jira project key, e.g. `QA` |
| `jira-issue-type` | no | `Task` | Jira issue type |
| `jira-assignee-id` | no | — | Jira user account ID |
| `custom-prompt` | no | — | Additional prompt context for LLM |
| Name | Required | Description |
|------|----------|-------------|
| `github-token` | yes | GitHub token to fetch PR diff |
| `worker-url` | yes | Cloudflare Worker endpoint URL |
| `worker-secret` | yes | Shared secret for Worker authentication |

## Outputs

| Name | Description |
|------|-------------|
| `jira-issue-key` | Created Jira issue key, e.g. `QA-123` |
| `jira-issue-url` | URL to the created Jira issue |
| `jira-issue-key` | Created Jira issue key, e.g. `OK-123` (empty if skipped) |
| `jira-issue-url` | URL to the created Jira issue (empty if skipped) |
| `analysis-summary` | LLM generated impact summary |
| `skipped` | Whether QA was skipped (`true`/`false`) |

## Switching LLM Provider
## Worker Configuration

Uses OpenAI-compatible `/v1/chat/completions` endpoint. Switch by changing inputs:

```yaml
# DeepSeek (default, cost-effective for testing)
llm-api-base-url: https://api.deepseek.com
llm-model: deepseek-chat

# OpenAI
llm-api-base-url: https://api.openai.com
llm-model: gpt-4o

# Groq
llm-api-base-url: https://api.groq.com/openai
llm-model: llama-3.1-70b-versatile
```

## Jira Issue Output

The created Jira issue includes:

- **Change summary** — one-line description of what changed
- **Risk level** — high / medium / low with color indicators
- **Affected modules** — list of impacted areas
- **Test checklist** — actionable test steps (Jira task list format)
- **Regression areas** — what else to regression test
- **PR link** — direct link back to the merged PR
LLM, Jira, and user mapping configuration lives in the Cloudflare Worker, not in this action. See the Worker project for setup details.
38 changes: 7 additions & 31 deletions pr-impact-analysis/action.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,27 @@
name: 'PR Impact Analysis'
description: 'Analyze PR impact via LLM and create Jira issue for QA'
description: 'Analyze PR impact via Cloudflare Worker (LLM + Jira)'
branding:
icon: 'search'
color: 'blue'
inputs:
github-token:
description: 'GitHub token to fetch PR diff'
required: true
llm-api-key:
description: 'LLM API key'
worker-url:
description: 'Cloudflare Worker endpoint URL'
required: true
llm-api-base-url:
description: 'Full LLM API endpoint URL, e.g. https://api.openai.com/v1/chat/completions'
worker-secret:
description: 'Shared secret for Worker authentication'
required: true
llm-model:
description: 'Model name'
required: true
jira-base-url:
description: 'Jira instance URL, e.g. https://yourteam.atlassian.net'
required: true
jira-email:
description: 'Jira account email for API auth'
required: true
jira-api-token:
description: 'Jira API token'
required: true
jira-project-key:
description: 'Jira project key, e.g. QA'
required: true
jira-issue-type:
description: 'Jira issue type to create'
default: '测试 QA'
jira-assignee-id:
description: 'Jira user account ID to assign the issue to'
required: false
custom-prompt:
description: 'Additional prompt context for LLM analysis'
required: false
outputs:
jira-issue-key:
description: 'Created Jira issue key, e.g. QA-123 (empty if skipped)'
description: 'Created Jira issue key, e.g. OK-123 (empty if skipped)'
jira-issue-url:
description: 'URL to the created Jira issue (empty if skipped)'
analysis-summary:
description: 'LLM generated impact analysis summary'
skipped:
description: 'Whether QA was skipped (true/false)'
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'
Loading