-
Notifications
You must be signed in to change notification settings - Fork 8
51 lines (44 loc) · 1.92 KB
/
cicd-demo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Demo of how to use a CodeGuru Reviewer CLI release in CICD.
on: [ push, pull_request, workflow_dispatch ]
permissions:
id-token: write
contents: read
jobs:
RunDemo:
name: Run CodeGuru Reviewer CLI in CICD
runs-on: ubuntu-latest
steps:
# Setup Java 8 or higher.
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
# To configure this role, use this CDK example:
# https://github:com/aws-samples/aws-codeguru-reviewer-cicd-cdk-sample
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
continue-on-error: true
id: iam-role
with:
role-to-assume: arn:aws:iam::048169001733:role/GuruGitHubCICDRole
aws-region: us-west-2
# Only continue if fetching the AWS credentials was successful.
- uses: actions/checkout@v2
if: steps.iam-role.outcome == 'success'
with:
fetch-depth: 0 # the fetch depth needs to be provided if we only want to check a certain commit range.
- name: Build project
if: steps.iam-role.outcome == 'success'
run: ./gradlew clean installDist
# Download a release of the CodeGuru Reviewer CLI.
- name: Download CodeGuru Reviewer CLI
shell: bash
env:
VERSION: 0.2.4
run: curl -OL "https://github.com/aws/aws-codeguru-cli/releases/download/$VERSION/aws-codeguru-cli.zip"
- run: unzip aws-codeguru-cli.zip
# Run CodeGuru Reviewer on the current project and use the --fail-on-recommendations option to fail
# if any recommendations are reported.
- name: Run Code Guru
if: steps.iam-role.outcome == 'success'
run: ./aws-codeguru-cli/bin/aws-codeguru-cli --region us-west-2 -r ./ -s ./src/main/java -b ./build/classes/java/main -c "${{ github.event.before }}:${{ github.event.after }}" --no-prompt --fail-on-recommendations