feat: Add new demo GIF for tasks in landing page #38
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
| name: Continuous Deployment | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| deploy-backend: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS Credentials (OIDC) | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.IAM_ROLE_ARN }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Build, tag, and push image to ECR | |
| id: build-image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| IMAGE_URI="$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |
| LATEST_IMAGE_URI="$ECR_REGISTRY/$ECR_REPOSITORY:latest" | |
| EXISTING_IMAGE_TAG="$(aws ecr batch-get-image \ | |
| --repository-name "$ECR_REPOSITORY" \ | |
| --image-ids imageTag="$IMAGE_TAG" \ | |
| --query 'images[0].imageId.imageTag' \ | |
| --output text 2>/dev/null || true)" | |
| if [ "$EXISTING_IMAGE_TAG" = "$IMAGE_TAG" ]; then | |
| echo "Image already exists, skipping build." | |
| else | |
| docker build -t "$IMAGE_URI" -t "$LATEST_IMAGE_URI" ./backend | |
| docker push "$IMAGE_URI" | |
| docker push "$LATEST_IMAGE_URI" | |
| fi | |
| echo "image=$IMAGE_URI" >> $GITHUB_OUTPUT | |
| - name: Create ECS task definition (with secrets) | |
| run: | | |
| aws ecs describe-task-definition \ | |
| --task-definition ${{ secrets.ECS_TASK_DEFINITION_ARN }} \ | |
| --query 'taskDefinition' > base-task-def.json | |
| jq \ | |
| --arg IMAGE "${{ steps.build-image.outputs.image }}" \ | |
| --arg dbUrlArn "${{ secrets.DB_URL_SECRET_ARN }}" \ | |
| --arg jwtSecretArn "${{ secrets.JWT_SECRET_ARN }}" \ | |
| --arg githubClientIdArn "${{ secrets.CLIENT_ID_SECRET_ARN }}" \ | |
| --arg githubClientSecretArn "${{ secrets.CLIENT_SECRET_ARN }}" \ | |
| --arg githubRedirectUri "https://api.devsyncapp.me/api/v1/github/callback" \ | |
| --arg frontendUrl "https://www.devsyncapp.me" ' | |
| .containerDefinitions[0].image = $IMAGE | | |
| .containerDefinitions[0].secrets = [ | |
| { | |
| "name": "DATABASE_URL", | |
| "valueFrom": $dbUrlArn | |
| }, | |
| { | |
| "name": "JWT_SECRET_KEY", | |
| "valueFrom": $jwtSecretArn | |
| }, | |
| { | |
| "name": "GITHUB_CLIENT_ID", | |
| "valueFrom": $githubClientIdArn | |
| }, | |
| { | |
| "name": "GITHUB_CLIENT_SECRET", | |
| "valueFrom": $githubClientSecretArn | |
| } | |
| ] | | |
| .containerDefinitions[0].environment = ( | |
| (.containerDefinitions[0].environment // []) | |
| | map(select(.name != "GITHUB_REDIRECT_URI" and .name != "FRONTEND_URL")) | |
| + [ | |
| {"name": "GITHUB_REDIRECT_URI", "value": $githubRedirectUri}, | |
| {"name": "FRONTEND_URL", "value": $frontendUrl} | |
| ] | |
| ) | | |
| del(.taskDefinitionArn, .revision, .status, .requiresAttributes, .placementConstraints, .compatibilities, .registeredAt, .registeredBy) | |
| ' base-task-def.json > task-definition.json | |
| - name: Deploy to ECS | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@v2 | |
| with: | |
| task-definition: task-definition.json | |
| service: ${{ secrets.ECS_SERVICE }} | |
| cluster: ${{ secrets.ECS_CLUSTER }} | |
| wait-for-service-stability: true | |
| - name: Verify GitHub OAuth config | |
| run: | | |
| for i in {1..10}; do | |
| resp=$(curl -fsS https://api.devsyncapp.me/api/v1/github/config-check || true) | |
| echo "$resp" | grep -q '"client_id_set":true' && \ | |
| echo "$resp" | grep -q '"client_secret_set":true' && \ | |
| echo "$resp" | grep -q '"redirect_uri_set":true' && \ | |
| echo "$resp" | grep -q '"frontend_url":"https://www.devsyncapp.me"' && exit 0 | |
| echo "GitHub OAuth config not ready yet. Retrying..." | |
| sleep 10 | |
| done | |
| echo "GitHub OAuth config check failed." | |
| exit 1 | |
| deploy-frontend: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| needs: deploy-backend | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: npm | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Build frontend | |
| working-directory: frontend | |
| env: | |
| REACT_APP_API_URL: ${{ secrets.PRODUCTION_API_URL }} | |
| run: npm run build | |
| - name: Configure AWS Credentials (OIDC) | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.IAM_ROLE_ARN }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Sync to S3 | |
| run: | | |
| aws s3 sync ./frontend/build s3://${{ secrets.S3_BUCKET_NAME }} --delete | |
| - name: Invalidate CloudFront cache | |
| run: | | |
| aws cloudfront create-invalidation \ | |
| --distribution-id ${{ secrets.CLOUDFRONT_DIST_ID }} \ | |
| --paths "/*" |