bun913 / userstory-review-by-bedrock-action

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

userstory-review-by-bedrock-action

GitHub Super-Linter CI Check dist/ CodeQL Coverage

日本語ドキュメントはこちら

This GitHub Action utilizes Amazon Bedrock's Claude 3 Sonnet (anthropic.claude-3-sonnet-20240229-v1:0) to review user stories submitted to it, based on the following criteria:

  • Is the story written from the perspective of the requester?
  • Are acceptance criteria defined and testable?
  • Is the feature clearly defined and distinguishable from others?
  • Does the story adhere to commonly used formats?
    • As a [type of user], I want [some goal] so that [some reason].

Important

Please note that this is currently intended for use in Japanese.

How to use

Prerequisites

Example Configuration for User Stories in GitHub Issues

For instance, by setting up your .github/workflows/*.yml like the following, you can automate reviewing user stories registered as GitHub Issues, adding or removing labels, etc.

name: User Story Review
on:
  issues:
    types: [opened, edited, reopened]

jobs:
  add-review-comment:
    if: contains(github.event.issue.labels.*.name, 'user-story')
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
      issues: write

    steps:
      # Checkout the repository(Needed to access the issue body)
      - name: Checkout
        id: checkout
        uses: actions/checkout@v4

      # Configure AWS Credentials
      # You need to create a role in AWS IAM and provide the ARN here
      # And allows your role to bedrock access
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
          aws-region: us-east-1

      # Review User Story
      # (Issues with label 'user-story' will be reviewed by Bedrock AI)
      - name: Review User Story
        id: review
        uses: bun913/userstory-review-by-bedrock-action@v0.3.0
        with:
          bedrock_region: us-east-1
          issue_body: ${{ github.event.issue.body }}

      # Remove the 'ai-reviewed' label if it exists
      # You need to add 'ai-reviewed' label to the issue manually
      - name: Remove Reviewd Label
        if: contains(github.event.issue.labels.*.name, 'ai-reviewed')
        run: gh issue edit "$NUMBER" --remove-label "$LABELS"
        env:
          NUMBER: ${{ github.event.issue.number }}
          LABELS: 'ai-reviewed'
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # Add comment to issue(Review Result will be added as a comment to the issue)
      - name: Add comment to issue
        run: gh issue comment "$NUMBER" --body "$BODY"
        env:
          NUMBER: ${{ github.event.issue.number }}
          BODY: ${{ steps.review.outputs.review_result }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # If Review is completed, add 'ai-reviewed' label to the issue
      # You need to add 'ai-reviewed' label to the issue manually
      - name: Add Label to issue
        if: contains(steps.review.outputs.review_result, 'Review Completed.')
        run: gh issue edit "$NUMBER" --add-label "$LABELS"
        env:
          NUMBER: ${{ github.event.issue.number }}
          LABELS: 'ai-reviewed'
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

For Developers

If you fork this repository and make changes, you need to set the required repository secrets as follows:

  • AWS_ROLE_ARN: The ARN of the IAM role that allows access to Bedrock
  • AWS_REGION: The region where Bedrock is deployed

About

License:MIT License


Languages

Language:TypeScript 81.9%Language:Shell 18.1%