Skip to content

Disable editing while video is processing #687

Disable editing while video is processing

Disable editing while video is processing #687

name: Cypress E2E Tests (Preview Deployment)
on:
pull_request:
types: [ready_for_review, synchronize, opened]
paths-ignore:
- docs/**
- '**.md'
- '**.png'
- '**.jpg'
env:
AWS_REGION: ca-central-1 # set this to your preferred AWS region, e.g. us-west-1
ECR_REPOSITORY: harp-video # set this to your Amazon ECR repository name
ECS_SERVICE: harp-video-website-staging-deployment # set this to your Amazon ECS service name
ECS_CLUSTER: HarpVideoDeployment # set this to your Amazon ECS cluster name
ECS_TASK_DEFINITION: aws/amazon-ecs-preview-deployment-task-definition.json # set this to the path to your Amazon ECS task definition
# file, e.g. .aws/task-definition.json
CONTAINER_NAME: harp-video # set this to the name of the container in the containerDefinitions section of your task definition
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
concurrency: preview
jobs:
deploy-preview:
name: Deploy
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
environment: preview
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create env File
run: |
echo "${{ secrets.STAGING_ENV_FILE }}" > .env
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::932748244514:role/GithubActionRole
role-session-name: GithubActionRole
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile.prod .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
setup-db:
name: Migrate Database
runs-on: ubuntu-latest
needs: ['deploy-preview']
steps:
- uses: actions/checkout@v4
- name: Write environment variables
run: |
echo "${{ secrets.STAGING_ENV_FILE }}" > .env
- name: Install Packages
run: |
npm ci
- name: Generate Prisma
run: |
npx prisma generate
- name: Migrate Database
run: npx prisma migrate reset --force &>-
cypress-e2e:
name: Run Cypress E2E Tests on Preview Deployment
runs-on: ubuntu-latest
needs: [deploy-preview, setup-db]
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Write environment variables
run: |
echo "${{ secrets.STAGING_ENV_FILE }}" > .env
- name: Install Packages
run: |
npm ci
- name: Generate Prisma
run: |
npx prisma generate
- name: Run Cypress Tests
run: |
npx cypress run
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
if-no-files-found: ignore
- name: Upload videos
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: cypress/videos
if-no-files-found: ignore
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-test-results
path: cypress/reports/e2e/e2e*.json
results-report:
name: Report results
runs-on: ubuntu-latest
needs: [cypress-e2e]
permissions:
pull-requests: write
issues: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Download test results
uses: actions/download-artifact@v4
with:
name: e2e-test-results
path: cypress/reports
- name: Merge reports to 1 report file
run: |
npx mochawesome-merge cypress/reports/*.json > cypress/reports/test_results.json
- name: Convert report file to markdown
run: |
npx [email protected] -p cypress/reports/test_results.json -o cypress/reports/test_results.md --reportTitle="E2E Test Results"
- name: Try to find existing report comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.number }}
body-includes: E2E Test Results
- name: Create report and post on PR
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.number }}
body-path: cypress/reports/test_results.md
edit-mode: replace