-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Develop #35
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ba55e1f
ops: update frontend-cd
Zaiidmo ddc6de4
ops: update workflow permissions
Zaiidmo 2ca1c87
Auth (#24)
Zaiidmo a50af97
Frontend (#30)
Zaiidmo 150a57e
Fix: merge conflict in lockfile
Zaiidmo 265b8f7
ops: update CI workflows names for status checks
Zaiidmo 73c44c7
Frontend (#34)
Zaiidmo af95ff9
Merge branch 'develop' of github.com:CISCODE-MA/comptaleyes-be into d…
Zaiidmo 0d4b0c5
ui: updated index html and added logo & favicon
Zaiidmo 6de9c33
ui: added frontend scripts to the global workspace and updated logo p…
Zaiidmo 5ea9d9e
ops: update deployment pipelines
Zaiidmo 0750b63
fix: fix syntax error in frontend-cd
Zaiidmo a01c6b8
Updated merge conflicts
Zaiidmo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,120 +1,129 @@ | ||
| name: CD - Frontend (S3 + CloudFront Deploy) [Manual] | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [master] | ||
| paths: | ||
| - "frontend/**" | ||
| - "package.json" | ||
| - "package-lock.json" | ||
| - ".github/workflows/frontend-cd.yml" | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [master] | ||
| paths: | ||
| - "frontend/**" | ||
| - "package.json" | ||
| - "package-lock.json" | ||
| - ".github/workflows/frontend-cd.yml" | ||
|
|
||
| concurrency: | ||
| group: cd-frontend-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| group: cd-frontend-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| jobs: | ||
| deploy: | ||
| name: Deploy frontend to S3 + invalidate CloudFront | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Check if frontend exists | ||
| id: fe | ||
| run: | | ||
| if [ -f "frontend/package.json" ]; then | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Configure AWS credentials (OIDC) | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_GHA_ROLE_ARN }} | ||
| aws-region: us-east-1 | ||
|
|
||
| - name: Resolve CloudFormation outputs (bucket + distribution) | ||
| id: cf | ||
| run: | | ||
| set -euo pipefail | ||
| STACK="ComptaleyesFrontendStack" | ||
|
|
||
| BUCKET_NAME="$(aws cloudformation describe-stacks \ | ||
| --stack-name "$STACK" \ | ||
| --query "Stacks[0].Outputs[?OutputKey=='FrontendBucketName'].OutputValue | [0]" \ | ||
| --output text)" | ||
|
|
||
| DIST_ID="$(aws cloudformation describe-stacks \ | ||
| --stack-name "$STACK" \ | ||
| --query "Stacks[0].Outputs[?OutputKey=='CloudFrontDistributionId'].OutputValue | [0]" \ | ||
| --output text)" | ||
|
|
||
| if [ -z "$BUCKET_NAME" ] || [ "$BUCKET_NAME" = "None" ]; then | ||
| echo "Missing FrontendBucketName output in $STACK" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$DIST_ID" ] || [ "$DIST_ID" = "None" ]; then | ||
| echo "Missing CloudFrontDistributionId output in $STACK" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "bucket_name=$BUCKET_NAME" >> "$GITHUB_OUTPUT" | ||
| echo "distribution_id=$DIST_ID" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # This will only run once frontend/package.json exists. | ||
| - name: Setup Node | ||
| if: steps.fe.outputs.exists == 'true' | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "22" | ||
| cache: "npm" | ||
|
|
||
| - name: Install (workspaces) | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: npm ci | ||
|
|
||
| - name: Build frontend (placeholder) | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: npm -w frontend run build | ||
|
|
||
| - name: Verify build output exists (placeholder expects frontend/dist) | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| if [ ! -d "frontend/dist" ]; then | ||
| echo "Expected build output folder frontend/dist not found." | ||
| echo "When you create the frontend, ensure the build outputs to frontend/dist, or update this workflow." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Deploy to S3 (sync) | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| aws s3 sync "frontend/dist" "s3://${{ steps.cf.outputs.bucket_name }}" --delete | ||
|
|
||
| - name: Invalidate CloudFront | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| aws cloudfront create-invalidation \ | ||
| --distribution-id "${{ steps.cf.outputs.distribution_id }}" \ | ||
| --paths "/*" | ||
|
|
||
| - name: Skip (frontend not initialized yet) | ||
| if: steps.fe.outputs.exists != 'true' | ||
| run: | | ||
| echo "frontend/package.json not found; frontend CD is intentionally a placeholder." | ||
| echo "CloudFormation lookup succeeded (infra is ready)." | ||
| echo "Once frontend exists, re-run this workflow." | ||
| deploy: | ||
| name: Deploy frontend to S3 + invalidate CloudFront | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| env: | ||
| API_BASE_URL: ${{ secrets.FRONTEND_API_BASE_URL }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Check if frontend exists | ||
| id: fe | ||
| run: | | ||
| if [ -f "frontend/package.json" ]; then | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Configure AWS credentials (OIDC) | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_GHA_ROLE_ARN }} | ||
| aws-region: us-east-1 | ||
|
|
||
| - name: Resolve CloudFormation outputs (bucket + distribution) | ||
| id: cf | ||
| run: | | ||
| set -euo pipefail | ||
| STACK="ComptaleyesFrontendStack" | ||
|
|
||
| BUCKET_NAME="$(aws cloudformation describe-stacks \ | ||
| --stack-name "$STACK" \ | ||
| --query "Stacks[0].Outputs[?OutputKey=='FrontendBucketName'].OutputValue | [0]" \ | ||
| --output text)" | ||
|
|
||
| DIST_ID="$(aws cloudformation describe-stacks \ | ||
| --stack-name "$STACK" \ | ||
| --query "Stacks[0].Outputs[?OutputKey=='CloudFrontDistributionId'].OutputValue | [0]" \ | ||
| --output text)" | ||
|
|
||
| if [ -z "$BUCKET_NAME" ] || [ "$BUCKET_NAME" = "None" ]; then | ||
| echo "Missing FrontendBucketName output in $STACK" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$DIST_ID" ] || [ "$DIST_ID" = "None" ]; then | ||
| echo "Missing CloudFrontDistributionId output in $STACK" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "bucket_name=$BUCKET_NAME" >> "$GITHUB_OUTPUT" | ||
| echo "distribution_id=$DIST_ID" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # This will only run once frontend/package.json exists. | ||
| - name: Setup Node | ||
| if: steps.fe.outputs.exists == 'true' | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "22" | ||
| cache: "npm" | ||
|
|
||
| - name: Install (workspaces) | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: npm ci | ||
|
|
||
| - name: Build frontend (placeholder) | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: npm -w frontend run build | ||
|
|
||
| - name: Write frontend env (Vite) | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| : "${API_BASE_URL:?Set FRONTEND_API_BASE_URL secret to your backend URL}" | ||
| echo "VITE_BACKEND_URL=${API_BASE_URL}" >> frontend/.env.production | ||
|
|
||
| - name: Verify build output exists (placeholder expects frontend/dist) | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| if [ ! -d "frontend/dist" ]; then | ||
| echo "Expected build output folder frontend/dist not found." | ||
| echo "When you create the frontend, ensure the build outputs to frontend/dist, or update this workflow." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Deploy to S3 (sync) | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| aws s3 sync "frontend/dist" "s3://${{ steps.cf.outputs.bucket_name }}" --delete | ||
|
|
||
| - name: Invalidate CloudFront | ||
| if: steps.fe.outputs.exists == 'true' | ||
| run: | | ||
| set -euo pipefail | ||
| aws cloudfront create-invalidation \ | ||
| --distribution-id "${{ steps.cf.outputs.distribution_id }}" \ | ||
| --paths "/*" | ||
|
|
||
| - name: Skip (frontend not initialized yet) | ||
| if: steps.fe.outputs.exists != 'true' | ||
| run: | | ||
| echo "frontend/package.json not found; frontend CD is intentionally a placeholder." | ||
| echo "CloudFormation lookup succeeded (infra is ready)." | ||
| echo "Once frontend exists, re-run this workflow." | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.