Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spotify
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoStreaming
Plugins
Spotify
Commits
bbfda9de
Commit
bbfda9de
authored
9 months ago
by
Koen
Browse files
Options
Downloads
Patches
Plain Diff
Added CI/CD.
parent
0541ec4a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+9
-0
9 additions, 0 deletions
.gitlab-ci.yml
build/deploy.sh
+0
-1
0 additions, 1 deletion
build/deploy.sh
deploy.sh
+25
-0
25 additions, 0 deletions
deploy.sh
sign.sh
+29
-0
29 additions, 0 deletions
sign.sh
with
63 additions
and
1 deletion
.gitlab-ci.yml
0 → 100644
+
9
−
0
View file @
bbfda9de
stages
:
-
deploy
deploy
:
stage
:
deploy
script
:
-
sh deploy.sh
only
:
-
master
This diff is collapsed.
Click to expand it.
build/deploy.sh
deleted
100644 → 0
+
0
−
1
View file @
0541ec4a
#!/bin/sh
\ No newline at end of file
This diff is collapsed.
Click to expand it.
deploy.sh
0 → 100644
+
25
−
0
View file @
bbfda9de
#!/bin/sh
DOCUMENT_ROOT
=
/var/www/sources
# Take site offline
echo
"Taking site offline..."
touch
$DOCUMENT_ROOT
/maintenance.file
# Swap over the content
echo
"Deploying content..."
mkdir
-p
$DOCUMENT_ROOT
/Spotify
cp
build/SpotifyIcon.png
$DOCUMENT_ROOT
/Spotify
cp
build/SpotifyConfig.json
$DOCUMENT_ROOT
/Spotify
cp
build/SpotifyScript.js
$DOCUMENT_ROOT
/Spotify
sh sign.sh
$DOCUMENT_ROOT
/Spotify/SpotifyScript.js
$DOCUMENT_ROOT
/Spotify/SpotifyConfig.json
# Notify Cloudflare to wipe the CDN cache
echo
"Purging Cloudflare cache for zone
$CLOUDFLARE_ZONE_ID
..."
curl
-X
POST
"https://api.cloudflare.com/client/v4/zones/
$CLOUDFLARE_ZONE_ID
/purge_cache"
\
-H
"Authorization: Bearer
$CLOUDFLARE_API_TOKEN
"
\
-H
"Content-Type: application/json"
\
--data
'{"files":["https://plugins.grayjay.app/Spotify/SpotifyIcon.png", "https://plugins.grayjay.app/Spotify/SpotifyConfig.json", "https://plugins.grayjay.app/Spotify/SpotifyScript.js"]}'
# Take site back online
echo
"Bringing site back online..."
rm
$DOCUMENT_ROOT
/maintenance.file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
sign.sh
0 → 100644
+
29
−
0
View file @
bbfda9de
#!/bin/sh
# Parameters
JS_FILE_PATH
=
$1
CONFIG_FILE_PATH
=
$2
# Decode and save the private key to a temporary file
echo
"
$SIGNING_PRIVATE_KEY
"
|
base64
-d
>
tmp_private_key.pem
# Validate private key
if
!
openssl rsa
-check
-noout
-in
tmp_private_key.pem
>
/dev/null 2>&1
;
then
echo
"Invalid private key."
rm
tmp_private_key.pem
exit
1
fi
# Generate signature for the provided JS file
SIGNATURE
=
$(
cat
$JS_FILE_PATH
| openssl dgst
-sha512
-sign
tmp_private_key.pem |
base64
-w
0
)
# Extract public key from the temporary private key file
PUBLIC_KEY
=
$(
openssl rsa
-pubout
-outform
DER
-in
tmp_private_key.pem 2>/dev/null | openssl pkey
-pubin
-inform
DER
-outform
PEM |
tail
-n
+2 |
head
-n
-1
|
tr
-d
'\n'
)
echo
"PUBLIC_KEY:
$PUBLIC_KEY
"
# Remove temporary key files
rm
tmp_private_key.pem
# Update "scriptSignature" and "scriptPublicKey" fields in Config JSON
cat
$CONFIG_FILE_PATH
| jq
--arg
signature
"
$SIGNATURE
"
--arg
publicKey
"
$PUBLIC_KEY
"
'. + {scriptSignature: $signature, scriptPublicKey: $publicKey}'
>
temp_config.json
&&
mv
temp_config.json
$CONFIG_FILE_PATH
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment