-
-
Notifications
You must be signed in to change notification settings - Fork 10
131 lines (107 loc) · 4.67 KB
/
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
name: CD Azure
on:
push:
branches:
- main
permissions:
pull-requests: write
id-token: write
jobs:
build_and_deploy:
name: Build & Deploy to ${{ matrix.environment }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- environment: Test
url: https://dev.www.jabref.org
deployment_environment: dev
- environment: Staging
url: https://staging.www.jabref.org
deployment_environment: staging
- environment: Production
url: https://www.jabref.org
deployment_environment: default
environment:
name: ${{ matrix.environment }}
url: ${{ matrix.url }}
env:
DATABASE_URL: ${{ matrix.environment == 'Test' && secrets.AZURE_TEST_DATABASE_URL || secrets.AZURE_DATABASE_URL }}
GITHUB_REPO_TOKEN: ${{ secrets.GITHUBS_REPO_TOKEN }}
NUXT_SESSION_PASSWORD: ${{ secrets.AZURE_SESSION_SECRET }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Reset Test database on Azure
if: matrix.environment == 'Test'
run: pnpm prisma:migrate:reset --force
- name: Update Production database on Azure
if: matrix.environment == 'Staging'
run: pnpm prisma:migrate:deploy
- name: Build
run: pnpm build:azure
- name: Login to Azure
uses: Azure/login@a65d910e8af852a8061c627c456678983e180302 # v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy Web App
run: |
# Delete old deployment (otherwise we get a spawn EBUSY error when running the workflow again)
az staticwebapp environment delete --name jabref-online --environment-name ${{ matrix.deployment_environment }} --yes || true
pnpm swa deploy .output\public --env ${{ matrix.deployment_environment }}
env:
SWA_CLI_DEPLOYMENT_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PEBBLE_0224C3803 }}
- name: Install Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: '3.10'
- name: Create & Link Function App
run: |
pip install azure-identity azure-mgmt-web azure-mgmt-storage azure-mgmt-applicationinsights azure-mgmt-redis azure-mgmt-communication
python .github\scripts\deploy.py --env ${{ matrix.deployment_environment }}
env:
SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy Function App
run: |
# Nuxt/nitro creates symlinks to replicate parts of the node_modules folder
# if multiple versions of the same package are used.
# However, these symlinks are not preserved by Compress-Archive, and even they were, Azure has problems with symlinks:
# https://github.com/Azure/webapps-deploy/issues/54
# Therefore, replace all symlinks by the actual files
$links = Get-ChildItem -Path .output\server -Attributes ReparsePoint -Recurse
foreach ($link in $links)
{
$source = $link.Target;
$destination = $link.FullName;
Remove-Item $destination -Force
Copy-Item -Path $source -Destination $destination -Force -Recurse
}
Compress-Archive -Path .output\server\* -DestinationPath .output\server.zip
az functionapp deployment source config-zip -g JabRefOnline -n jabref-function-${{ matrix.deployment_environment }} --src .output\server.zip
- name: Check HTTP status
run: |
Start-Sleep -Seconds 30
curl -s -w 'Establish Connection: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' ${{ matrix.url }} || true
curl -s -w 'Establish Connection: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' ${{ matrix.url }}/api || true
# The api returns 400 status code for some reason
# with:
# url: ${{ matrix.url }}/api
# code: 200
# timeout: 300 # initial warm up can take quite some time
# interval: 30
- name: Run E2E tests
run: pnpm test:e2e
env:
TEST_URL: ${{ matrix.url }}