-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathentrypoint.sh
executable file
·43 lines (39 loc) · 1.09 KB
/
entrypoint.sh
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
#!/bin/sh
set -e
deploy_with_webhook() {
curl \
--fail \
--silent \
--show-error \
--user-agent "Forge-GitHubAction/1.0" \
--max-time 5 \
--connect-timeout 5 \
--request 'POST' \
"$TRIGGER_URL"
}
deploy_with_api() {
curl \
--fail \
--silent \
--show-error \
--user-agent "Forge-GitHubAction/1.0" \
--max-time 5 \
--connect-timeout 5 \
--request 'POST' \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
"https://forge.laravel.com/api/v1/servers/$SERVER_ID/sites/$SITE_ID/deployment/deploy"
}
if [ -n "$TRIGGER_URL" ]; then
deploy_with_webhook
elif [ -n "$API_KEY" ]; then
if [ -z "$SERVER_ID" ] || [ -z "$SITE_ID" ]; then
echo "SERVER_ID and SITE_ID environment variables must be set. Exiting."
exit 1
fi
deploy_with_api
else
echo "Either a TRIGGER_URL or API_KEY environment variable must be set to use the Laravel Forge GitHub Action. Exiting."
exit 1
fi