<!-- json
{
  "sourceId": "embracinglife-cloudfront-deploy",
  "repositoryId": "v2-embracing-life",
  "filePath": ".github/workflows/deploy-ui.yml",
  "capabilityTags": ["workflow", "aws", "cloudfront", "s3"],
  "operationIds": ["workflow-cloudfront-deploy"],
  "applicability": ["sample-project"],
  "notes": [
    "Reference UI deployment sync and invalidation workflow pattern."
  ]
}
-->

# embracinglife-cloudfront-deploy

- Source: `.github/workflows/deploy-ui.yml`
- Capability tags: workflow, aws, cloudfront, s3
- Applicability: sample-project
- Notes:
  - Reference UI deployment sync and invalidation workflow pattern.

## Reference Code

```yaml
---
on:
  push:
    branches:
      - main 
    paths:
    - ui/**
    - .github/workflows/deploy-ui.yml  
  workflow_dispatch: {}

name: Deploy the UI
env:
  MAX_AGE: 31557600
  S3_ROOT: v2embracinglife/site
  DISTRIBUTION_ID: E2JYQOXH7WY3JR
jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
      - name: Checkout source code
        uses: actions/checkout@v6

      - uses: actions/setup-node@v6
        with:
          node-version: 25.7.x
          cache: 'npm'        

      - name: Install deps
        run: npm i
    
      - name: Build
        run: npx trvc build       

      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v5
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Install
        run: npm i
        working-directory: ui
      - name: Run Prebuild
        run: npm run prebuild
        working-directory: ui        
      - name: Build
        run: NG_BUILD_OPTIMIZE_CHUNKS=1 npx @angular/cli build --configuration production
        working-directory: ui
      - name: Copy Static Files to S3
        run: aws s3 sync --delete --metadata-directive REPLACE --cache-control 'public,max-age=${{ env.MAX_AGE }}' dist/browser s3://${{ env.S3_ROOT }}
        working-directory: ui
      - name: Invalidate Distribution Cache
        run: ./scripts/invalidation.sh ${{ env.DISTRIBUTION_ID }}
      - name: Prime cache
        run: ./scripts/prime-cache.sh
```
