Skip to content

Add public-samples/golf-swing-recording--n6oxdk/src/web/src/types/coa… #121

Add public-samples/golf-swing-recording--n6oxdk/src/web/src/types/coa…

Add public-samples/golf-swing-recording--n6oxdk/src/web/src/types/coa… #121

Workflow file for this run

name: Web Application CI/CD
on:
push:
branches: [main, develop]
paths:
- 'src/web/**'
- '.github/workflows/web.yml'
pull_request:
branches: [main, develop]
paths:
- 'src/web/**'
- '.github/workflows/web.yml'
env:
NODE_VERSION: '18.x'
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
NEXT_PUBLIC_SOCKET_URL: ${{ secrets.NEXT_PUBLIC_SOCKET_URL }}
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}
NEXT_TELEMETRY_DISABLED: 1
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
jobs:
setup:
name: Setup Environment
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'src/web/package-lock.json'
- name: Cache dependencies
uses: actions/cache@v3
id: npm-cache
with:
path: |
src/web/node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('src/web/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
working-directory: src/web
run: |
npm ci --audit
npm audit fix
lint-and-type-check:
name: Lint and Type Check
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'src/web/package-lock.json'
- name: Restore cache
uses: actions/cache@v3
with:
path: |
src/web/node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('src/web/package-lock.json') }}
- name: Run ESLint
working-directory: src/web
run: npm run lint
- name: Run TypeScript type checking
working-directory: src/web
run: npm run type-check
unit-tests:
name: Unit Tests
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'src/web/package-lock.json'
- name: Restore cache
uses: actions/cache@v3
with:
path: |
src/web/node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('src/web/package-lock.json') }}
- name: Run Jest tests with coverage
working-directory: src/web
run: npm run test:coverage
- name: Upload coverage reports
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: src/web/coverage
retention-days: 14
e2e-tests:
name: E2E Tests
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'src/web/package-lock.json'
- name: Restore cache
uses: actions/cache@v3
with:
path: |
src/web/node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('src/web/package-lock.json') }}
- name: Run Cypress tests
uses: cypress-io/github-action@v6
with:
working-directory: src/web
build: npm run build
start: npm start
wait-on: 'http://localhost:3000'
record: true
env:
CYPRESS_RECORD_KEY: ${{ env.CYPRESS_RECORD_KEY }}
build:
name: Build Application
needs: [lint-and-type-check, unit-tests, e2e-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'src/web/package-lock.json'
- name: Restore cache
uses: actions/cache@v3
with:
path: |
src/web/node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('src/web/package-lock.json') }}
- name: Generate bundle analysis
working-directory: src/web
run: |
ANALYZE=true npm run build
env:
NEXT_PUBLIC_API_URL: ${{ env.NEXT_PUBLIC_API_URL }}
NEXT_PUBLIC_SOCKET_URL: ${{ env.NEXT_PUBLIC_SOCKET_URL }}
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: ${{ env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-output
path: |
src/web/.next
src/web/public
retention-days: 7
deploy:
name: Deploy to Production
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
environment: production
concurrency: production_deployment
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-output
path: src/web/.next
- name: Deploy to S3
run: |
aws s3 sync src/web/.next s3://${{ secrets.AWS_S3_BUCKET }}/web --delete
aws s3 sync src/web/public s3://${{ secrets.AWS_S3_BUCKET }}/web/public --delete
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \
--paths "/*"
- name: Verify deployment
run: |
curl -sSf ${{ secrets.PRODUCTION_URL }}/_next/health > /dev/null
echo "Deployment health check passed"
- name: Update deployment status
if: always()
run: |
if [ "${{ job.status }}" = "success" ]; then
echo "Deployment completed successfully"
else
echo "Deployment failed"
exit 1
fi