From 29d333d3678f9b766cf078dc8fed93e3efe5bf97 Mon Sep 17 00:00:00 2001 From: yike5460 Date: Wed, 9 Oct 2024 08:13:02 +0000 Subject: [PATCH] feat: enable code review and pr description in workflow --- .github/aws-genai-cicd-suite.yml | 74 ++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/aws-genai-cicd-suite.yml diff --git a/.github/aws-genai-cicd-suite.yml b/.github/aws-genai-cicd-suite.yml new file mode 100644 index 0000000..aa42fdc --- /dev/null +++ b/.github/aws-genai-cicd-suite.yml @@ -0,0 +1,74 @@ +name: Intelligent Code Review +# Enable manual trigger +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize] + + # Avoid running the same workflow on the same branch concurrently +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + review: + runs-on: ubuntu-latest + permissions: + # read repository contents and write pull request comments + id-token: write + # allow github action bot to push new content into existing pull requests + contents: write + # contents: read + pull-requests: write + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install dependencies + run: npm ci + shell: bash + + # check if required dependencies @actions/core and @actions/github are installed + - name: Check if required dependencies are installed + run: | + npm list @actions/core + npm list @actions/github + shell: bash + + - name: Debug GitHub Token + run: | + if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then + echo "GitHub Token is set" + else + echo "GitHub Token is not set" + fi + + # assume the specified IAM role and set up the AWS credentials for use in subsequent steps. + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + # using repository secret to get the role arn + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws-region: us-east-1 + + - name: Intelligent GitHub Actions + uses: aws-samples/aws-genai-cicd-suite@stable + with: + # Automatic Provision: The GITHUB_TOKEN is automatically created and provided by GitHub for each workflow run. You don't need to manually create or store this token as a secret. + github-token: ${{ secrets.GITHUB_TOKEN }} + aws-region: us-east-1 + model-id: anthropic.claude-3-sonnet-20240229-v1:0 + generate-code-review: 'true' + generate-code-review-level: 'detailed' + generate-code-review-exclude-files: '*.md,*.json,*.js' + generate-pr-description: 'true' + generate-unit-test: 'false' + generate-unit-test-source-folder: 'debugging' + # Removed the invalid input 'generate-unit-test-exclude-files' + # output-language: 'zh' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file