-
Notifications
You must be signed in to change notification settings - Fork 8
141 lines (125 loc) · 4.18 KB
/
pr-push-deploy.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: PR - build and deploy to slot
on:
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: ci-${{ github.event.number }}-${{ github.workflow }}
cancel-in-progress: true
defaults:
run:
shell: pwsh
jobs:
run-tests-and-coverage:
name: Run tests & coverage
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v4
with:
package_json_file: package.json
- name: Install dependencies
run: pnpm install
- name: Run Tests & Coverage
run: pnpm test-and-coverage --outputFile=coverage-report.json
- name: Upload Coverage Report to PR
uses: ArtiomTr/jest-coverage-report-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
coverage-file: coverage-report.json
base-coverage-file: coverage-report.json
skip-step: all
annotations: none
build:
name: Build and upload artifacts
uses: ./.github/workflows/template-build.yml
with:
tag: pr-${{ github.event.number }}
permissions:
id-token: write
contents: read
secrets: inherit
pr-deploy:
name: Deploy to slot
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: write
outputs:
url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v4
- name: Load .env file
uses: xom9ikk/dotenv@v2
with:
path: ./.github
- name: Deploy to slot
uses: ./.github/actions/deploy
id: deploy
with:
slot_name: pr-${{ github.event.number }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_RESOURCE_GROUP: ${{ env.AZURE_RESOURCE_GROUP }}
APP_SERVICE_NAME: ${{ env.APP_SERVICE_NAME }}
ACR_LOGIN_SERVER: ${{ env.ACR_LOGIN_SERVER }}
IMAGE_NAME: ${{ env.IMAGE_NAME }}
AZURE_SERVICE_PRINCIPAL_OBJECT_ID: ${{ secrets.AZURE_SERVICE_PRINCIPAL_OBJECT_ID }}
- name: Comment on PR
uses: mshick/add-pr-comment@v2
with:
message: |
Deployed changes to <${{ steps.deploy.outputs.url }}>
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true
ui-test:
name: Run Playwright Tests
needs: pr-deploy
uses: ./.github/workflows/template-ui-tests.yml
with:
deploy_url: ${{ needs.pr-deploy.outputs.url }}
tests_to_run: "images seo-noindex"
pagespeedInsights:
name: Run PageSpeed Insights
needs: pr-deploy
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: wicksipedia/pagespeed-insights@main
id: pagespeed-insights
with:
url: ${{ needs.pr-deploy.outputs.url }}
categories: |
accessibility
best_practices
performance
SEO
strategy: mobile
delayBetweenRetries: 30000
maximumNumberOfRetries: 4
key: ${{ secrets.PAGESPEED_INSIGHTS_API_KEY }}
- name: Comment on PR with insights
uses: mshick/add-pr-comment@v2
with:
message: |
## PageSpeed Insights
| Category | Score |
| --- | --- |
| Accessibility | ${{ steps.pagespeed-insights.outputs.accessibility }} |
| Best practices | ${{ steps.pagespeed-insights.outputs.best_practices }} |
| Performance | ${{ steps.pagespeed-insights.outputs.performance }} |
| SEO | ${{ steps.pagespeed-insights.outputs.seo }} |
View the full report <https://pagespeed.web.dev/report?url=${{ needs.pr-deploy.outputs.url }}>
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true