-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (184 loc) · 7.04 KB
/
pullpreview-dispatch.yml
File metadata and controls
199 lines (184 loc) · 7.04 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: PullPreview Dispatch
run-name: PullPreview Dispatch (${{ inputs.action }}) - ${{ inputs.preview_name }}
on:
workflow_dispatch:
inputs:
action:
description: "PullPreview action"
required: true
default: up
type: choice
options:
- up
- down
preview_name:
description: "Deterministic preview identifier (used as PullPreview label)"
required: true
type: string
integrationSetupMethod:
description: "Integration setup mode"
required: true
default: sso-external
type: choice
options:
- sso-external
- sso-nextcloud
- oauth2
openproject_version:
description: "Optional OpenProject docker tag override"
required: false
type: string
nextcloud_version:
description: "Optional Nextcloud image tag override"
required: false
type: string
keycloak_version:
description: "Optional Keycloak image tag override"
required: false
type: string
integration_app_version:
description: "Optional integration_openproject app version (alias if integration_openproject_version is empty)"
required: false
type: string
integration_openproject_version:
description: "integration_openproject app version (overrides integration_app_version when set)"
required: false
type: string
integration_openproject_git_branch:
description: "integration_openproject git branch (ignored if empty; version ignored when set)"
required: false
type: string
openproject_branch:
description: "Optional OpenProject git source branch override"
required: false
type: string
nextcloud_branch:
description: "Optional Nextcloud git source branch override"
required: false
type: string
permissions:
contents: read
jobs:
deploy_or_teardown:
runs-on: ubuntu-latest
timeout-minutes: 70
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
steps:
- uses: actions/checkout@v6
- id: pullpreview_up
if: inputs.action == 'up'
uses: pullpreview/action@65df5209b58f360444525f1167f9e14803521fed
with:
provider: hetzner
label: ${{ inputs.preview_name }}
force_action: up
region: fsn1
image: ubuntu-24.04
instance_type: cpx42
dns: my.preview.run
max_domain_length: "40"
deployment_target: helm
chart: ./charts/pullpreview-stack
chart_values: pullpreview/stack-values.yaml.gotmpl
proxy_tls: traefik:80
proxy_tls_hosts: nextcloud.{{ pullpreview_public_dns }},keycloak.{{ pullpreview_public_dns }}
ttl: 72h
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
HETZNER_CA_KEY: ${{ secrets.HETZNER_CA_KEY }}
OPENPROJECT_ENTERPRISE_TOKEN: ${{ secrets.OPENPROJECT_ENTERPRISE_TOKEN }}
INTEGRATION_SETUP_METHOD: ${{ inputs.integrationSetupMethod }}
OPENPROJECT_VERSION: ${{ inputs.openproject_version }}
NEXTCLOUD_VERSION: ${{ inputs.nextcloud_version }}
KEYCLOAK_VERSION: ${{ inputs.keycloak_version }}
INTEGRATION_APP_VERSION: ${{ inputs.integration_app_version }}
INTEGRATION_OPENPROJECT_VERSION: ${{ inputs.integration_openproject_version }}
INTEGRATION_OPENPROJECT_GIT_BRANCH: ${{ inputs.integration_openproject_git_branch }}
OPENPROJECT_BRANCH: ${{ inputs.openproject_branch }}
NEXTCLOUD_BRANCH: ${{ inputs.nextcloud_branch }}
- name: Validate preview URLs
if: inputs.action == 'up' && steps.pullpreview_up.outputs.live == 'true'
shell: bash
run: |
set -euo pipefail
preview_url="${{ steps.pullpreview_up.outputs.url }}"
preview_host="${preview_url#https://}"
preview_host="${preview_host#http://}"
preview_host="${preview_host%%/*}"
preview_host="${preview_host%%:*}"
check_url() {
local name="$1"
local url="$2"
local expected_status="$3"
local attempt
local attempts=12
local status=""
local curl_exit=0
for attempt in $(seq 1 "${attempts}"); do
set +e
status="$(
/usr/bin/curl -skS -o /dev/null \
--connect-timeout 10 \
--write-out '%{http_code}' \
"$url" 2>/dev/null
)"
curl_exit=$?
set -e
if [[ "${curl_exit}" -eq 0 ]]; then
echo "${name}: ${url} -> ${status} (attempt ${attempt}/${attempts})"
if [[ "${status}" == "${expected_status}" ]]; then
return 0
fi
else
echo "${name}: ${url} -> curl-exit-${curl_exit} (attempt ${attempt}/${attempts})"
fi
sleep 10
done
echo "::group::Debug: response headers for ${name}"
/usr/bin/curl -skS -D- -o /dev/null "$url" 2>&1 | head -n 50 || true
echo "::endgroup::"
echo "::error::${name} endpoint was not ready: ${url} expected HTTP ${expected_status}, last result ${status}"
return 1
}
check_url "Main root" "https://${preview_host}/" "302"
check_url "Main login" "https://${preview_host}/login" "200"
check_url "Nextcloud" "https://nextcloud.${preview_host}/status.php" "200"
check_url "Keycloak" "https://keycloak.${preview_host}/realms/opnc" "200"
- name: Build preview info artifact
if: inputs.action == 'up'
shell: bash
run: |
set -euo pipefail
preview_url="${{ steps.pullpreview_up.outputs.url }}"
preview_host="${preview_url#https://}"
preview_host="${preview_host#http://}"
preview_host="${preview_host%%/*}"
preview_host="${preview_host%%:*}"
cat > preview-info.json <<EOF
{
"preview_name": "${{ inputs.preview_name }}",
"preview_url": "${preview_url}",
"preview_host": "${preview_host}",
"nextcloud_url": "https://nextcloud.${preview_host}",
"keycloak_url": "https://keycloak.${preview_host}/realms/opnc",
"live": "${{ steps.pullpreview_up.outputs.live }}"
}
EOF
- name: Upload preview info artifact
if: inputs.action == 'up'
uses: actions/upload-artifact@v4
with:
name: pullpreview-info
path: preview-info.json
- id: pullpreview_down
if: inputs.action == 'down'
uses: pullpreview/action@65df5209b58f360444525f1167f9e14803521fed
with:
provider: hetzner
label: ${{ inputs.preview_name }}
force_action: down
deployment_target: helm
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
HETZNER_CA_KEY: ${{ secrets.HETZNER_CA_KEY }}