-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (107 loc) · 4.1 KB
/
deploy-and-run-cypress.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Deploy and run test with API
# Build and deploy test instance for every pull request
on:
workflow_dispatch:
inputs:
api_url:
required: true
description: 'Build dashboard and run test with this API url'
type: string
tags:
required: true
description: 'Run tests with typed tags'
type: string
default: "@stable"
jobs:
deploy:
runs-on: ubuntu-latest
outputs:
base_URL: ${{ steps.set-domain.outputs.domain }}
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/github-slug-action@e4699e49fcf890a3172a02c56ba78d867dbb9fd5
- name: Start deployment
uses: bobheadxi/deployments@2666faab9444f09ccd666f2dbe67687a5f6512f0
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.GITHUB_HEAD_REF_SLUG_URL }}
ref: ${{ github.head_ref }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-qa-${{ env.cache-name }}-
${{ runner.os }}-qa-
${{ runner.os }}-
- name: Install deps
run: |
npm ci
- name: Run build
env:
API_URI: ${{github.event.inputs.api_url}}
APP_MOUNT_URI: /
STATIC_URL: /
IS_CLOUD_INSTANCE: true
run: |
npm run build
- name: Set domain
id: set-domain
# Set test instance domain based on branch name slug
run: |
echo "domain=test-deploy-${{ env.GITHUB_HEAD_REF_SLUG_URL }}.dashboard.saleor.rocks" >> $GITHUB_OUTPUT
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Deploy to S3
run: |
aws s3 sync ./build/dashboard s3://${{ secrets.AWS_TEST_DEPLOYMENT_BUCKET }}/${{ steps.set-domain.outputs.domain }}
- name: Invalidate cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_TEST_CF_DIST_ID }} --paths "/${{ steps.set-domain.outputs.domain }}/*"
- name: Update deployment status
uses: bobheadxi/deployments@2666faab9444f09ccd666f2dbe67687a5f6512f0
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env_url: https://${{ steps.set-domain.outputs.domain }}/
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
cypress-run:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Cypress run critical
uses: cypress-io/github-action@v4
env:
API_URI: ${{github.event.inputs.api_url}}
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }}
CYPRESS_baseUrl: https://${{needs.deploy.outputs.base_URL}}
CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
COMMIT_INFO_MESSAGE: ${{github.event.inputs.tags}} tests triggered on PR - https://github.com/${{ github.repository }}/pull/${{ github.ref_name }}
CYPRESS_grepTags: ${{github.event.inputs.tags}}
with:
record: true
tag: ${{github.event.inputs.tags}}, buildAndRun