ci-cd.yml•6.15 kB
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
NODE_VERSION: '20'
PNPM_VERSION: '8'
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build application
run: pnpm run build
- name: Run tests
run: pnpm run test
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-files
path: dist/
security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run security audit
run: pnpm audit --audit-level moderate
- name: Run CodeQL Analysis
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: [test, security-scan]
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
environment: staging
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }}
aws-region: ${{ secrets.AWS_REGION_STAGING }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build application
run: pnpm run build
- name: Deploy to AWS (Staging)
run: |
cd cdk
cdk deploy --all --require-approval never --context environment=staging
- name: Deploy Lambda functions
run: ./scripts/deploy-aws.sh
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
needs: [test, security-scan]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build application
run: pnpm run build
- name: Deploy infrastructure to AWS
run: |
cd cdk
cdk deploy --all --require-approval never
- name: Deploy Lambda functions
run: ./scripts/deploy-aws.sh
- name: Deploy web interface
run: ./scripts/deploy-web.sh ${{ secrets.WEB_BUCKET_NAME }}
- name: Run health check
run: |
API_URL=$(cd cdk && cdk describe McpPromptsStack | jq -r '.McpPromptsStack.ApiGatewayUrl')
echo "API URL: $API_URL"
curl -f "$API_URL/health" || exit 1
- name: Create deployment notification
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 **Production deployment completed successfully!**\n\nAPI: ${{ steps.api-url.outputs.url }}\nWeb: ${{ steps.web-url.outputs.url }}`
})
release:
name: Create Release
runs-on: ubuntu-latest
needs: [deploy-production]
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && contains(github.event.head_commit.message, 'release:')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version.outputs.version }}
release_name: Release v${{ steps.version.outputs.version }}
body: |
## What's new in v${{ steps.version.outputs.version }}
### Features
- Subscription management with Stripe integration
- Slash commands for quick prompt execution
- Modern web interface for user management
- Rate limiting and access control
### Improvements
- Enhanced AWS infrastructure with Cognito authentication
- Improved error handling and logging
- Better TypeScript types and validation
draft: false
prerelease: false