Repository navigation
161 lines (139 loc) · 4.42 KB
/
Copy pathci-cd.yml
File metadata and controls
161 lines (139 loc) · 4.42 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: CI-CD
on:
push:
branches:
- main
tags:
- "**"
pull_request:
branches:
- "**"
permissions:
contents: read
packages: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check for SCSS changes
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
scss:
- 'src/**/*.scss'
- '.stylelintrc*'
- 'stylelint.config.*'
- 'package.json'
- name: Cache dependencies
uses: actions/setup-node@v7
with:
node-version-file: .tool-versions
cache: "yarn"
- name: Install code
run: yarn install --immutable
- name: eslint
run: yarn lint
- name: stylelint
if: steps.changes.outputs.scss == 'true'
run: yarn stylelint
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Cache dependencies
uses: actions/setup-node@v7
with:
node-version-file: .tool-versions
cache: "yarn"
- name: Install code
run: yarn install --immutable
- name: Run tests
run: yarn test --run
env:
REACT_APP_API_ENDPOINT: http://localhost:3009
REACT_APP_SCRATCH_FRAME_URL: "http://scratch-frame.example.com"
- name: Run Scratch Frame tests
run: yarn run test:scratch-frame
test-cypress:
runs-on: ubuntu-latest
env:
REACT_APP_API_ENDPOINT: "https://test-editor-api.raspberrypi.org"
PUBLIC_URL: "http://localhost:3011"
ASSETS_URL: "http://localhost:3011"
REACT_APP_ALLOWED_IFRAME_ORIGINS: "http://localhost:3011"
CSP_API_MULTIPLE_ORIGINS: "http://localhost:3011,http://localhost:3009"
REACT_APP_SCRATCH_FRAME_URL: "http://localhost:3014"
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Cache dependencies
uses: actions/setup-node@v7
with:
node-version-file: .tool-versions
cache: "yarn"
- name: Install code
run: yarn install --immutable
- name: Build code
run: yarn build:all
- name: Cypress run
uses: cypress-io/github-action@v7
with:
install: false
start: |
yarn preview:all
wait-on: "http://localhost:3011, http://localhost:3014/scratch.html"
quiet: true
config-file: cypress.config.mjs
browser: chrome
- name: Archive cypress artifacts
uses: actions/upload-artifact@v4.6.0
if: failure()
with:
name: cypress-artifacts
path: |
cypress/screenshots
deploy-tag:
if: github.ref_type == 'tag'
needs: [lint, test, test-cypress]
uses: ./.github/workflows/deploy.yml
with:
base_url: https://editor-static.raspberrypi.org
assets_url: https://editor-static.raspberrypi.org
html_renderer_url: https://editor-static.raspberrypi.org
environment: production
prefix: releases
react_app_api_endpoint: https://editor-api.raspberrypi.org
react_app_authentication_url: https://auth-v1.raspberrypi.org
react_app_base_url: ""
react_app_google_tag_manager_id: GTM-5FWFWFJ
react_app_sentry_dsn: https://a6d7b79c7a474a6499ace73acf792a83@o17504.ingest.sentry.io/4504055099621376
react_app_sentry_env: production
react_app_allowed_iframe_origins: "https://editor.raspberrypi.org,https://editor-static.raspberrypi.org,https://classroom.raspberrypi.org,https://projects.raspberrypi.org"
secrets: inherit
deploy-main:
if: github.ref_type == 'branch' && github.ref_name == 'main'
needs: [lint, test, test-cypress]
uses: ./.github/workflows/deploy.yml
with:
environment: staging
react_app_base_url: ""
react_app_sentry_env: staging
csp_api_multiple_origins: "https://staging-editor-api.raspberrypi.org https://test-editor-api.raspberrypi.org"
secrets: inherit
dispatch-e2e:
if: github.ref == 'refs/heads/main'
needs: [deploy-main]
uses: ./.github/workflows/dispatch-learner-experience-e2e.yml
with:
ref: main
secrets: inherit
deploy-branch:
if: github.ref_type == 'branch' && github.ref_name != 'main'
uses: ./.github/workflows/deploy.yml
with:
environment: previews/${{ github.ref_name }}
secrets: inherit