-
-
Notifications
You must be signed in to change notification settings - Fork 429
83 lines (72 loc) · 2.46 KB
/
prtests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: 👩🏻🚀 MAIN -> E2E Tests + Preview Deploy (Frontend)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
DEPLOY_PR_FROM_FORK: true
on:
pull_request_target:
types: [opened, synchronize, reopened]
branches:
- main
jobs:
cypress-run:
runs-on: ubuntu-latest
# use docker container to run tests
container: cypress/browsers:node18.12.0-chrome107
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install npm
run: npm install -g husky
- name: set environment variables
uses: allenevans/[email protected]
with:
HUSKY: 0
- name: "Cypress Tests - Chrome"
uses: cypress-io/[email protected]
with:
install: true
build: npm run build
start: npm run dev
wait-on: "http://localhost:3000"
wait-on-timeout: 120
browser: chrome
spec: cypress/e2e/*
env:
CI: "false"
Deploy-Preview:
needs: cypress-run
if: success()
runs-on: ubuntu-latest
steps:
- id: script
uses: actions/github-script@v3
with:
script: |
const isPr = [ 'pull_request', 'pull_request_target' ].includes(context.eventName)
core.setOutput('ref', isPr ? context.payload.pull_request.head.ref : context.ref)
core.setOutput('repo', isPr ? context.payload.pull_request.head.repo.full_name : context.repo.full_name)
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ steps.script.outputs.repo }}
- name: Create Branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: "${{ github.event.pull_request.head.ref }}"
sha: "${{ github.event.pull_request.head.sha }}"
- name: Deploy to Vercel Action
uses: BetaHuhn/deploy-to-vercel-action@latest
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
DEPLOY_PR_FROM_FORK: true
DELETE_EXISTING_COMMENT: true
PR_LABELS: false