-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathspin_deploy.sh
More file actions
executable file
·39 lines (33 loc) · 1.14 KB
/
spin_deploy.sh
File metadata and controls
executable file
·39 lines (33 loc) · 1.14 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
#!/usr/bin/env bash
set -evxo pipefail
cache restore "nixpkgs-last-successful-sha"
LAST_SHA=$(cat "nixpkgs-last-successful-sha" || echo "$SEMAPHORE_GIT_SHA")
SHA_SHORT=$(git rev-parse --short=8 "$SEMAPHORE_GIT_SHA")
AUTHOR_EMAIL=$(git show -s --format='%ae' "$SEMAPHORE_GIT_SHA")
ALL_AUTHORS=$(git log --format="%ae" "$LAST_SHA".."$SEMAPHORE_GIT_SHA" | sort | uniq | paste -sd "," -)
cat <<EOF >payload.json
{
"url": "webhooks/webhook/nixpkgs-replit",
"method": "POST",
"body": {
"secret": "$SPIN_SECRET",
"parameters": {
"sha": "$SEMAPHORE_GIT_SHA",
"sha_range": "$LAST_SHA...$SEMAPHORE_GIT_SHA",
"sha_short": "$SHA_SHORT",
"last_author": "$AUTHOR_EMAIL",
"all_authors": "$ALL_AUTHORS",
"rollback_pipeline": "webhooks/webhook/nixpkgs-replit-rollback",
"scratch": "false"
}
}
}
EOF
curl --fail -X POST \
-H "$WEBHOOK_AUTH" \
-H "content-type: application/json" \
-d @payload.json \
"$WEBHOOK_URL"
git rev-parse --verify "$SEMAPHORE_GIT_SHA" >"nixpkgs-last-successful-sha"
cache delete "nixpkgs-last-successful-sha"
cache store "nixpkgs-last-successful-sha" "nixpkgs-last-successful-sha"