Skip to content

Changed migrate command #126

Changed migrate command

Changed migrate command #126

name: Cypress E2E Tests (Preview Deployment)
#on:
# workflow_dispatch:
# inputs:
# run_deploy:
# description: 'Run deploy-preview job'
# required: false
# type: boolean
# default: false
on:
push:
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: amazon-ecs-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
jobs:
deploy-preview:
name: Deploy
runs-on: ubuntu-latest
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 deploy
cypress-e2e:
name: Run Cypress E2E Tests on Preview Deployment
runs-on: ubuntu-latest
needs: [ deploy-preview, setup-db]
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
# cypress-e2e:
# name: Run cypress E2E tests on preview deployment
# runs-on: ubuntu-latest
# if: always()
# needs: [ deploy-preview, setup-db ]
# outputs:
# PR_ID: ${{ steps.save-cypress-outputs.outputs.PR_ID }}
# steps:
# - uses: actions/checkout@v4
# - name: Write environment variables
# run: |
# echo "${{ secrets.STAGING_ENV_FILE }}" > .env
# - name: Generate Prisma
# run: |
# npx prisma generate
# - name: Cypress Run E2E Tests
# uses: cypress-io/github-action@v6
# env:
# GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_ACCESS_TOKEN }}
# with:
# wait-on: http://harp-video-staging-balancer-1212142463.ca-central-1.elb.amazonaws.com/
# browser: chrome
# headed: true
# config: baseUrl="http://harp-video-staging-balancer-1212142463.ca-central-1.elb.amazonaws.com/"
# - name: Upload screenshots
# uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: cypress-screenshots
# path: cypress/screenshots
# if-no-files-found: ignore
# - name: Upload videos
# uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: cypress-videos
# path: cypress/videos
# if-no-files-found: ignore
# - name: Save cypress outputs
# if: always()
# id: save-cypress-outputs
# run: |
# echo "PR_ID=$CYPRESS_PULL_REQUEST_ID" >> $GITHUB_OUTPUT
# - name: Upload test results
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: e2e-test-results
# path: cypress/reports/e2e/e2e*.json
#
# results-report:
# name: Report results
# runs-on: ubuntu-latest
# if: always()
# needs: [ cypress-e2e ]
# steps:
# - uses: actions/checkout@v4
# - name: Download test results
# uses: actions/download-artifact@v3
# 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 mochawesome-json-to-md@0.7.2 -p cypress/reports/test_results.json -o cypress/reports/test_results.md --reportTitle="E2E Test Results"
# - name: Create report and post on PR
# uses: peter-evans/create-or-update-comment@v3
# env:
# PR_ID: ${{ needs.cypress-e2e.outputs.PR_ID }}
# with:
# issue-number: ${{ env.PR_ID }}
# body-path: cypress/reports/test_results.md
# token: ${{ secrets.PERSONAL_GITHUB_ACCESS_TOKEN }}