Skip to content

Commit 03ee8cd

Browse files
Prepare CodeAnt CI Scan action for testing
1 parent cd24d31 commit 03ee8cd

File tree

2 files changed

+127
-29
lines changed

2 files changed

+127
-29
lines changed

README.md

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
# CodeAnt CI Scan Action
1+
# CodeAnt Quality Gate Scan Action
22

3-
This GitHub Action runs CodeAnt CI security and code quality analysis on your repository. It integrates seamlessly with your CI/CD pipeline to provide automated code scanning and security insights.
3+
This GitHub Action runs CodeAnt CI quality gate scan with secret detection and code quality analysis on your repository. It integrates seamlessly with your CI/CD pipeline to provide automated scanning and will fail your workflow if secrets are detected or quality gates fail.
44

55
## Features
66

7-
- 🔒 Security vulnerability detection
8-
- 📊 Code quality analysis
7+
- 🔒 Secret detection and security scanning
8+
- 📊 Code quality gate enforcement
99
- 🚀 Fast and efficient scanning
1010
- 🔄 Seamless CI/CD integration
1111
- 📈 Detailed reports and insights
12+
- ⏱️ Configurable polling and timeout
13+
- ✅ Pass/Fail workflow status based on scan results
1214

1315
## Inputs
1416

1517
| Name | Description | Required | Default |
1618
|---------------|--------------------------------------------------|----------|--------------------------|
1719
| access_token | GitHub PAT or repository token for authentication | Yes | - |
1820
| api_base | Base URL for CodeAnt API | No | https://api.codeant.ai |
21+
| timeout | Maximum time in seconds to wait for results | No | 300 |
22+
| poll_interval | Time in seconds between polling attempts | No | 15 |
1923

2024
## Usage
2125

@@ -40,14 +44,41 @@ jobs:
4044
access_token: ${{ secrets.GITHUB_TOKEN }}
4145
```
4246
43-
### Custom API Base URL
47+
### With Custom Configuration
4448
4549
```yaml
46-
- name: Run CodeAnt Scan
50+
- name: Run CodeAnt Quality Gate Scan
4751
uses: CodeAnt-AI/codeant-ci-scan@v1
4852
with:
4953
access_token: ${{ secrets.ACCESS_TOKEN_GITHUB }}
50-
api_base: https://custom.codeant.ai
54+
api_base: https://api.codeant.ai
55+
timeout: 600 # Wait up to 10 minutes for results
56+
poll_interval: 20 # Poll every 20 seconds
57+
```
58+
59+
### Complete Workflow Example
60+
61+
```yaml
62+
name: CodeAnt Quality Gate
63+
64+
on:
65+
push:
66+
branches: [ main, develop ]
67+
pull_request:
68+
branches: [ main ]
69+
70+
jobs:
71+
quality-gate:
72+
name: Quality Gate Scan
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Run CodeAnt Quality Gate Scan
76+
uses: CodeAnt-AI/codeant-ci-scan@v1
77+
with:
78+
access_token: ${{ secrets.GITHUB_TOKEN }}
79+
api_base: https://api.codeant.ai
80+
timeout: 300
81+
poll_interval: 15
5182
```
5283
5384
## Testing from Another Repository
@@ -72,6 +103,28 @@ uses: CodeAnt-AI/codeant-ci-scan@feature-branch
72103
uses: CodeAnt-AI/codeant-ci-scan@abc1234 # commit SHA
73104
```
74105

106+
## How It Works
107+
108+
1. **Checkout**: Checks out your repository code
109+
2. **Fetch Script**: Downloads the quality gates scanning script from CodeAnt API
110+
3. **Start Scan**: Initiates the quality gate scan on CodeAnt servers
111+
4. **Poll Results**: Continuously polls for scan results until completion or timeout
112+
5. **Report Status**: Reports pass/fail status with GitHub annotations
113+
114+
## Expected Output
115+
116+
### When Quality Gate Passes:
117+
```
118+
✅ Quality Gate PASSED - No secrets detected
119+
```
120+
The workflow continues successfully.
121+
122+
### When Quality Gate Fails:
123+
```
124+
❌ Quality Gate FAILED - Secrets detected or scan error
125+
```
126+
The workflow fails, preventing merge/deployment.
127+
75128
## Required Permissions
76129
77130
The `access_token` requires the following permissions:

action.yml

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: "CodeAnt CI Scan"
2-
description: "Runs CodeAnt CI security and code quality analysis on your GitHub repository"
1+
name: "CodeAnt Quality Gate Scan"
2+
description: "Runs CodeAnt CI quality gate scan with secret detection and code quality analysis on your GitHub repository"
33
author: "CodeAnt AI"
44

55
branding:
@@ -14,48 +14,93 @@ inputs:
1414
description: "Base URL for CodeAnt API (e.g., https://api.codeant.ai)"
1515
required: true
1616
default: "https://api.codeant.ai"
17+
timeout:
18+
description: "Maximum time in seconds to wait for quality gate results (default: 300)"
19+
required: false
20+
default: "300"
21+
poll_interval:
22+
description: "Time in seconds between polling attempts (default: 15)"
23+
required: false
24+
default: "15"
1725

1826
runs:
1927
using: "composite"
2028
steps:
2129
- name: Checkout repository
2230
uses: actions/checkout@v4
2331

24-
- name: Fetch CodeAnt scan script
32+
- name: Fetch quality gates script
2533
shell: bash
2634
env:
2735
API_BASE: ${{ inputs.api_base }}
2836
run: |
2937
set -e
30-
echo "Fetching CodeAnt scan script from ${API_BASE}..."
31-
if ! curl -fsSL -X GET "${API_BASE}/analysis/ci/scan/script/get" --output start_scan.sh.b64; then
32-
echo "Error: Failed to fetch scan script from ${API_BASE}"
38+
echo "Fetching quality gates script from ${API_BASE}..."
39+
if ! curl -fsSL -X GET "${API_BASE}/analysis/ci/quality-gates/script/get" --output quality_gates.sh.b64; then
40+
echo "Error: Failed to fetch quality gates script from ${API_BASE}"
3341
exit 1
3442
fi
35-
echo "Successfully fetched scan script"
43+
echo "Successfully fetched quality gates script"
3644
37-
- name: Prepare scan script
45+
- name: Prepare quality gates script
3846
shell: bash
3947
run: |
4048
set -e
41-
if ! base64 -d start_scan.sh.b64 > start_scan.sh; then
42-
echo "Error: Failed to decode scan script"
49+
if ! base64 -d quality_gates.sh.b64 > quality_gates.sh; then
50+
echo "Error: Failed to decode quality gates script"
4351
exit 1
4452
fi
45-
chmod +x start_scan.sh
46-
echo "Scan script prepared successfully"
53+
chmod +x quality_gates.sh
54+
echo "Quality gates script prepared successfully"
4755
48-
- name: Run CodeAnt analysis
56+
- name: Start Quality Gate Scan
4957
shell: bash
58+
env:
59+
ACCESS_TOKEN: ${{ inputs.access_token }}
60+
REPO_NAME: ${{ github.repository }}
61+
COMMIT_ID: ${{ github.sha }}
62+
run: |
63+
set -e
64+
echo "Starting quality gate scan..."
65+
./quality_gates.sh \
66+
-a "$ACCESS_TOKEN" \
67+
-r "$REPO_NAME" \
68+
-c "$COMMIT_ID" \
69+
-s github \
70+
-o start
71+
echo "Quality gate scan initiated successfully"
72+
73+
- name: Poll for Quality Gate Results
74+
shell: bash
75+
env:
76+
ACCESS_TOKEN: ${{ inputs.access_token }}
77+
REPO_NAME: ${{ github.repository }}
78+
COMMIT_ID: ${{ github.sha }}
79+
TIMEOUT: ${{ inputs.timeout }}
80+
POLL_INTERVAL: ${{ inputs.poll_interval }}
5081
run: |
5182
set -e
52-
echo "Starting CodeAnt analysis..."
53-
bash start_scan.sh \
54-
-a "${{ inputs.access_token }}" \
55-
-r "${{ github.repository }}" \
56-
-c "${{ github.sha }}" \
57-
-b "${{ github.ref_name }}" \
83+
echo "Polling for quality gate results..."
84+
echo "Timeout: ${TIMEOUT}s, Poll Interval: ${POLL_INTERVAL}s"
85+
./quality_gates.sh \
86+
-a "$ACCESS_TOKEN" \
87+
-r "$REPO_NAME" \
88+
-c "$COMMIT_ID" \
5889
-s github \
59-
-i "" \
60-
-e ""
61-
echo "CodeAnt analysis completed"
90+
-o results \
91+
-t "$TIMEOUT" \
92+
-p "$POLL_INTERVAL"
93+
echo "Quality gate results retrieved successfully"
94+
95+
- name: Quality Gate Status
96+
if: always()
97+
shell: bash
98+
run: |
99+
if [ "${{ job.status }}" = "success" ]; then
100+
echo "✅ Quality Gate PASSED - No secrets detected"
101+
echo "::notice title=Quality Gate::Quality gate passed successfully"
102+
else
103+
echo "❌ Quality Gate FAILED - Secrets detected or scan error"
104+
echo "::error title=Quality Gate::Quality gate failed - please review the detected issues"
105+
exit 1
106+
fi

0 commit comments

Comments
 (0)