-
-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (120 loc) · 4.76 KB
/
Preview-Env-Create.yaml
File metadata and controls
136 lines (120 loc) · 4.76 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Create Preview Environment
on:
merge_group:
types:
- checks_requested
pull_request:
branches:
- main
concurrency:
group: preview-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
PreviewDeploy:
environment: Preview
name: Deploy Preview
timeout-minutes: 15
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true
- uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
install: true
- name: Install DevSpace
uses: loft-sh/setup-devspace@main
- name: Install Loft
uses: loft-sh/setup-loft@v2
with:
# version: v1.15.0
url: https://kube.bottled.codes
access-key: ${{ secrets.LOFT_ACCESS_KEY }}
- name: Create Preview Cluster
run: |
loft create vcluster once-preview${{ github.event.pull_request.number }} --project swytch --use --template preview-cluster --skip-wait
- name: Build image
run: |
loft use cluster
# build the current sha from the current branch
devspace use namespace once
devspace build -t ${{ github.sha }} --no-warn
- name: Wait for Preview Cluster
run: |
loft create vcluster once-preview${{ github.event.pull_request.number }} --project swytch --use --template preview-cluster
- name: Deploy
run: |
devspace use namespace once --no-warn
devspace deploy --no-warn -t ${{ github.sha }} --skip-build --skip-push \
--var STATE_SECRET="${{ secrets.STATE_SECRET }}" \
--var RETHINKDB_PASSWORD="${{ secrets.RETHINKDB_PASSWORD }}" \
--var AUTH_LOGIN="https://fake-auth.preview${{github.event.pull_request.number}}.once.getswytch.com/login" \
--var AUTH_URL="https://fake-auth.preview${{github.event.pull_request.number}}.once.getswytch.com/api/auth" \
--var AUTH_HOST="fake-auth.preview${{github.event.pull_request.number}}.once.getswytch.com" \
--var POSTMARK_API_KEY="${{ secrets.POSTMARK_SANDBOX_API_KEY }}" \
--var HOST="preview${{ github.event.pull_request.number }}.once.getswytch.com"
RETHINKDB_ADMIN_PASSWORD=${{ secrets.RETHINKDB_ADMIN_PASSWORD }} devspace run-pipeline db-migrate
- uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ github.event.pull_request.number }}
header: release
message: |
Preview environment deployed at: [https://preview${{ github.event.pull_request.number }}.once.getswytch.com](https://preview${{ github.event.pull_request.number }}.once.getswytch.com)
It may take a few minutes for DNS entries and certificates to propagate (you can add `65.108.6.254` to your hosts file).
e2e:
defaults:
run:
working-directory: tests/e2e
needs:
- PreviewDeploy
name: Run E2E Tests
timeout-minutes: 60
runs-on: self-hosted
strategy:
fail-fast: false
matrix:
project: [ chromium, firefox, webkit, 'Mobile Chrome', 'Mobile Safari' ]
shardIndex: [ 1 ]
shardTotal: [ 1 ]
include:
- project: chromium
browser: chromium
- project: firefox
browser: firefox
- project: webkit
browser: webkit
- project: 'Mobile Chrome'
browser: chromium
- project: 'Mobile Safari'
browser: webkit
steps:
- uses: actions/checkout@v3
- name: Configure hosts
run: |
# echo "167.235.212.77 preview${{ github.event.pull_request.number }}.once.getswytch.com" | sudo tee -a /etc/hosts
# echo "167.235.212.77 fake-auth.preview${{ github.event.pull_request.number }}.once.getswytch.com" | sudo tee -a /etc/hosts
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps ${{ matrix.browser }}
- name: Run Playwright tests
env:
APP_URL: https://preview${{ github.event.pull_request.number }}.once.getswytch.com
run: npx playwright test --project="${{ matrix.project }}" --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30