Skip to content

Commit 4237b79

Browse files
authored
Merge pull request #7 from YilingCAI/developer
Developer
2 parents e00ea2f + f613a01 commit 4237b79

159 files changed

Lines changed: 34233 additions & 5639 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/.commitlintrc.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# ============================================================
2+
# commitlint — Conventional Commits enforcement
3+
# Docs: https://commitlint.js.org
4+
# ============================================================
5+
extends:
6+
- "@commitlint/config-conventional"
7+
8+
rules:
9+
# Header length cap
10+
header-max-length: [2, "always", 100]
11+
12+
# Body must have a blank line above it (enforced by convention)
13+
body-leading-blank: [2, "always"]
14+
15+
# Footer must have a blank line above it
16+
footer-leading-blank: [1, "always"]
17+
18+
# Type must be one of the allowed types
19+
type-enum:
20+
- 2
21+
- "always"
22+
- - feat # new feature (triggers minor bump)
23+
- fix # bug fix (triggers patch bump)
24+
- perf # performance improvement (triggers patch bump)
25+
- refactor # code change that neither fixes a bug nor adds a feature
26+
- revert # revert a previous commit
27+
- docs # documentation only
28+
- style # formatting, missing semi-colons, etc.
29+
- test # adding or fixing tests
30+
- build # changes to build system or external dependencies
31+
- ci # changes to CI/CD configuration
32+
- chore # maintenance tasks
33+
34+
# Subject case: lower-case start is fine; forbid sentence/pascal/upper
35+
subject-case:
36+
- 2
37+
- "never"
38+
- [sentence-case, start-case, pascal-case, upper-case]
39+
40+
# Subject must not end with a period
41+
subject-full-stop: [2, "never", "."]
42+
43+
# Subject must not be empty
44+
subject-empty: [2, "never"]
45+
46+
# Type must not be empty
47+
type-empty: [2, "never"]

.github/.releaserc.json

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"branches": [
3+
"main",
4+
{
5+
"name": "hotfix/*",
6+
"prerelease": "hotfix"
7+
}
8+
],
9+
"tagFormat": "v${version}",
10+
"plugins": [
11+
[
12+
"@semantic-release/commit-analyzer",
13+
{
14+
"preset": "conventionalcommits",
15+
"releaseRules": [
16+
{
17+
"type": "feat",
18+
"release": "minor"
19+
},
20+
{
21+
"type": "fix",
22+
"release": "patch"
23+
},
24+
{
25+
"type": "perf",
26+
"release": "patch"
27+
},
28+
{
29+
"type": "revert",
30+
"release": "patch"
31+
},
32+
{
33+
"type": "refactor",
34+
"release": "patch"
35+
},
36+
{
37+
"type": "docs",
38+
"release": false
39+
},
40+
{
41+
"type": "style",
42+
"release": false
43+
},
44+
{
45+
"type": "test",
46+
"release": false
47+
},
48+
{
49+
"type": "build",
50+
"release": false
51+
},
52+
{
53+
"type": "ci",
54+
"release": false
55+
},
56+
{
57+
"type": "chore",
58+
"release": false
59+
},
60+
{
61+
"breaking": true,
62+
"release": "major"
63+
}
64+
]
65+
}
66+
],
67+
[
68+
"@semantic-release/release-notes-generator",
69+
{
70+
"preset": "conventionalcommits",
71+
"presetConfig": {
72+
"types": [
73+
{
74+
"type": "feat",
75+
"section": "✨ Features"
76+
},
77+
{
78+
"type": "fix",
79+
"section": "🐛 Bug Fixes"
80+
},
81+
{
82+
"type": "perf",
83+
"section": "⚡ Performance Improvements"
84+
},
85+
{
86+
"type": "revert",
87+
"section": "⏪ Reverts"
88+
},
89+
{
90+
"type": "refactor",
91+
"section": "♻️ Refactors",
92+
"hidden": false
93+
},
94+
{
95+
"type": "docs",
96+
"section": "📚 Documentation",
97+
"hidden": false
98+
},
99+
{
100+
"type": "ci",
101+
"section": "🔧 CI/CD",
102+
"hidden": false
103+
}
104+
]
105+
}
106+
}
107+
],
108+
[
109+
"@semantic-release/changelog",
110+
{
111+
"changelogFile": "CHANGELOG.md"
112+
}
113+
],
114+
[
115+
"@semantic-release/git",
116+
{
117+
"assets": [
118+
"CHANGELOG.md",
119+
".github/package.json"
120+
],
121+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
122+
}
123+
],
124+
"@semantic-release/github"
125+
]
126+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
###############################################################################
2+
# composite action: aws-auth
3+
#
4+
# Authenticates the GitHub Actions runner with AWS by assuming an IAM role
5+
# via OIDC (no long-lived credentials stored in secrets).
6+
#
7+
# Callers: ci.yml (terraform-plan), staging.yml (terraform-staging,
8+
# deploy-staging), release.yml (terraform-production,
9+
# deploy-production)
10+
# Inputs: role-arn, aws-region
11+
###############################################################################
12+
name: "AWS Authentication"
13+
description: "Authenticate with AWS using OIDC"
14+
15+
inputs:
16+
role-arn:
17+
description: "IAM role ARN to assume"
18+
required: true
19+
aws-region:
20+
description: "AWS region"
21+
required: false
22+
default: "us-east-1"
23+
session-name:
24+
description: "Session name for role assumption"
25+
required: false
26+
default: "github-actions"
27+
duration-seconds:
28+
description: "Duration of session in seconds"
29+
required: false
30+
default: "3600"
31+
32+
outputs:
33+
aws-account-id:
34+
description: "AWS Account ID"
35+
value: ${{ steps.aws-account.outputs.account-id }}
36+
aws-region:
37+
description: "AWS Region"
38+
value: ${{ inputs.aws-region }}
39+
40+
runs:
41+
using: "composite"
42+
steps:
43+
- name: Configure AWS credentials
44+
uses: aws-actions/configure-aws-credentials@v4
45+
with:
46+
role-to-assume: ${{ inputs.role-arn }}
47+
aws-region: ${{ inputs.aws-region }}
48+
role-session-name: ${{ inputs.session-name }}
49+
role-duration-seconds: ${{ inputs.duration-seconds }}
50+
51+
- name: Get AWS Account ID
52+
id: aws-account
53+
shell: bash
54+
run: |
55+
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
56+
echo "account-id=$ACCOUNT_ID" >> $GITHUB_OUTPUT
57+
echo "✓ AWS Authentication successful - Account: $ACCOUNT_ID"
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
###############################################################################
2+
# composite action: docker-build
3+
#
4+
# Builds a Docker image, optionally pushes it to a registry, and runs a
5+
# Trivy vulnerability scan on the resulting image.
6+
#
7+
# Callers: staging.yml (build job), release.yml (build-production job)
8+
# Inputs: context, dockerfile, image-name, registry, tags, build-args,
9+
# scan, scan-severity, scan-exit-code, cache-scope,
10+
# registry-username, registry-password
11+
###############################################################################
12+
name: "Docker Build"
13+
description: "Build and push Docker image to registry"
14+
15+
inputs:
16+
context:
17+
description: "Build context path"
18+
required: true
19+
dockerfile:
20+
description: "Dockerfile path"
21+
required: true
22+
image-name:
23+
description: "Image name (without registry)"
24+
required: true
25+
registry:
26+
description: "Container registry"
27+
required: false
28+
default: "ghcr.io"
29+
registry-username:
30+
description: "Registry username"
31+
required: false
32+
default: ""
33+
registry-password:
34+
description: "Registry password/token"
35+
required: false
36+
default: ""
37+
push:
38+
description: "Push to registry after build"
39+
required: false
40+
default: "true"
41+
scan:
42+
description: "Run Trivy vulnerability scan"
43+
required: false
44+
default: "true"
45+
scan-severity:
46+
description: "Trivy severities to include"
47+
required: false
48+
default: "CRITICAL,HIGH"
49+
scan-exit-code:
50+
description: "Trivy exit code on findings"
51+
required: false
52+
default: "0"
53+
tags:
54+
description: "docker/metadata-action tag rules"
55+
required: false
56+
default: ""
57+
build-args:
58+
description: "Additional Docker build args"
59+
required: false
60+
default: ""
61+
cache-scope:
62+
description: "GHA cache scope"
63+
required: false
64+
default: ""
65+
platforms:
66+
description: "Target platforms for image build"
67+
required: false
68+
default: "linux/amd64"
69+
cache:
70+
description: "Use GitHub Actions cache"
71+
required: false
72+
default: "true"
73+
cache-key-files:
74+
description: "Glob pattern for files to include in cache key (e.g., poetry.lock, package-lock.json, *.tf)"
75+
required: false
76+
default: ""
77+
78+
outputs:
79+
image-uri:
80+
description: "Full image URI"
81+
value: ${{ steps.meta.outputs.tags }}
82+
image-digest:
83+
description: "Image digest"
84+
value: ${{ steps.build.outputs.digest }}
85+
vulnerabilities-found:
86+
description: "Whether vulnerabilities were found"
87+
value: ${{ steps.trivy.outputs.vulnerabilities-found }}
88+
89+
runs:
90+
using: "composite"
91+
steps:
92+
- name: Set up Docker Buildx
93+
uses: docker/setup-buildx-action@v2
94+
95+
- name: Login to registry
96+
if: inputs.registry-username != '' && inputs.registry-password != ''
97+
uses: docker/login-action@v2
98+
with:
99+
registry: ${{ inputs.registry }}
100+
username: ${{ inputs.registry-username }}
101+
password: ${{ inputs.registry-password }}
102+
103+
- name: Generate dynamic cache key
104+
id: cache-key
105+
shell: bash
106+
run: |
107+
if [[ -n "${{ inputs.cache-key-files }}" ]]; then
108+
CACHE_KEY="docker-${{ inputs.image-name }}-${{ hashFiles(inputs.cache-key-files) }}"
109+
else
110+
CACHE_KEY="docker-${{ inputs.image-name }}-${{ github.sha }}"
111+
fi
112+
echo "key=${CACHE_KEY}" >> $GITHUB_OUTPUT
113+
114+
- name: Extract metadata
115+
id: meta
116+
uses: docker/metadata-action@v4
117+
with:
118+
images: ${{ inputs.registry }}/${{ inputs.image-name }}
119+
tags: ${{ inputs.tags != '' && inputs.tags || 'type=ref,event=branch\ntype=sha,prefix={{branch}}-\ntype=semver,pattern={{version}}\ntype=raw,value=latest,enable={{is_default_branch}}' }}
120+
121+
- name: Build and push Docker image
122+
id: build
123+
uses: docker/build-push-action@v4
124+
with:
125+
context: ${{ inputs.context }}
126+
file: ${{ inputs.dockerfile }}
127+
platforms: ${{ inputs.platforms }}
128+
push: ${{ inputs.push }}
129+
tags: ${{ steps.meta.outputs.tags }}
130+
labels: ${{ steps.meta.outputs.labels }}
131+
cache-from: ${{ inputs.cache == 'true' && format('type=gha,scope={0}', inputs.cache-scope != '' && inputs.cache-scope || inputs.image-name) || '' }}
132+
cache-to: ${{ inputs.cache == 'true' && format('type=gha,mode=max,scope={0}', inputs.cache-scope != '' && inputs.cache-scope || inputs.image-name) || '' }}
133+
build-args: |
134+
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
135+
VCS_REF=${{ github.sha }}
136+
VERSION=${{ github.ref_name }}
137+
${{ inputs.build-args }}
138+
139+
- name: Run Trivy vulnerability scan
140+
id: trivy
141+
if: inputs.scan == 'true'
142+
uses: aquasecurity/trivy-action@master
143+
with:
144+
image-ref: ${{ steps.meta.outputs.tags }}
145+
format: "sarif"
146+
output: "trivy-results.sarif"
147+
severity: ${{ inputs.scan-severity }}
148+
exit-code: ${{ inputs.scan-exit-code }}
149+
continue-on-error: true
150+
151+
- name: Upload Trivy results
152+
if: inputs.scan == 'true'
153+
uses: github/codeql-action/upload-sarif@v2
154+
with:
155+
sarif_file: "trivy-results.sarif"
156+
category: "trivy-docker-${{ inputs.image-name }}"
157+
continue-on-error: true
158+
159+
- name: Report build completion
160+
shell: bash
161+
run: |
162+
echo "✓ Docker image built and pushed"
163+
echo " Image: ${{ steps.meta.outputs.tags }}"
164+
echo " Digest: ${{ steps.build.outputs.digest }}"

0 commit comments

Comments
 (0)