mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
feat(other): deploy styleguide scripts and description (#8935)
This commit is contained in:
parent
b06b29b858
commit
ffffd9e15f
74
deployment/styleguide/README.md
Normal file
74
deployment/styleguide/README.md
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# Styleguide Deployment
|
||||||
|
|
||||||
|
You can use the webhook template `webhook.conf.template` and the `deploy-styleguide.sh` script in `deployment/styleguide/` for an automatic deployment from a (github) webhook.
|
||||||
|
|
||||||
|
For this to work follow these steps (using alpine):
|
||||||
|
|
||||||
|
Setup webhook service
|
||||||
|
```sh
|
||||||
|
apk add webhook
|
||||||
|
cp deployment/styleguide/hooks.json.template deployment/styleguide/hooks.json
|
||||||
|
vi deployment/styleguide/hooks.json
|
||||||
|
# adjust content of .github/webhooks/hooks.json
|
||||||
|
# replace all variables accordingly
|
||||||
|
|
||||||
|
# copy webhook service file
|
||||||
|
cp deployment/styleguide/webhook.template /etc/init.d/webhook
|
||||||
|
vi /etc/init.d/webhook
|
||||||
|
# adjust content of /etc/init.d/webhook
|
||||||
|
chmod +x /etc/init.d/webhook
|
||||||
|
|
||||||
|
service webhook start
|
||||||
|
rc-update add webhook boot
|
||||||
|
```
|
||||||
|
|
||||||
|
Setup nginx
|
||||||
|
```sh
|
||||||
|
vi /etc/nginx/http.d/default.conf
|
||||||
|
|
||||||
|
# contents of /etc/nginx/http.d/default.conf
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
root /var/www/localhost/htdocs;
|
||||||
|
|
||||||
|
# The github payload is quite big sometimes, hence those two lines can prevent an reoccurring error message on nginx
|
||||||
|
client_body_buffer_size 10M;
|
||||||
|
client_max_body_size 10M;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
index index.html;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /hooks/ {
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
|
||||||
|
proxy_pass http://127.0.0.1:9000/hooks/;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# contents of /etc/nginx/http.d/default.conf
|
||||||
|
|
||||||
|
service nginx reload
|
||||||
|
|
||||||
|
# delete htdocs/ folder to allow creation of symlink
|
||||||
|
rm -r /var/www/localhost/htdocs
|
||||||
|
```
|
||||||
|
|
||||||
|
For the github webhook configure the following:
|
||||||
|
|
||||||
|
| Field | Value |
|
||||||
|
|------------------------------------------------------|-----------------------------------------------|
|
||||||
|
| Payload URL | https://styleguide.ocelot.social/hooks/github |
|
||||||
|
| Content type | application/json |
|
||||||
|
| Secret | A SECRET |
|
||||||
|
| SSL verification | Enable SSL verification |
|
||||||
|
| Which events would you like to trigger this webhook? | Send me everything. |
|
||||||
|
| Active | [x] |
|
||||||
32
deployment/styleguide/deploy-styleguide.sh
Executable file
32
deployment/styleguide/deploy-styleguide.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Find current directory & configure paths
|
||||||
|
SCRIPT_PATH=$(realpath $0)
|
||||||
|
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
|
||||||
|
PROJECT_ROOT=$SCRIPT_DIR/../..
|
||||||
|
# by default this will create folders in the project root
|
||||||
|
DEPLOY_DIR=${1:-test}
|
||||||
|
BUILD_DIR=$PROJECT_ROOT/styleguide/docs
|
||||||
|
|
||||||
|
# assuming you are already on the right branch
|
||||||
|
git pull -ff
|
||||||
|
|
||||||
|
# Deploy physical Location
|
||||||
|
GIT_REF=$(git rev-parse --short HEAD)
|
||||||
|
DEPLOY_DIR_REF=$DEPLOY_DIR-$GIT_REF
|
||||||
|
|
||||||
|
## Parameter is a proper directory?
|
||||||
|
if [ -d "$DEPLOY_DIR_REF" ]; then
|
||||||
|
return "Directory '$DEPLOY_DIR_REF' does already exist" 2>/dev/null || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Build the project
|
||||||
|
cd $PROJECT_ROOT/styleguide
|
||||||
|
rm -R $BUILD_DIR
|
||||||
|
yarn install
|
||||||
|
yarn run build
|
||||||
|
|
||||||
|
## Copy files and Sym link to deploy dir
|
||||||
|
mkdir "$DEPLOY_DIR_REF/"
|
||||||
|
cp -r $BUILD_DIR/* "$DEPLOY_DIR_REF/"
|
||||||
|
ln -sfn "$DEPLOY_DIR_REF" $DEPLOY_DIR
|
||||||
37
deployment/styleguide/hooks.json.template
Normal file
37
deployment/styleguide/hooks.json.template
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "github",
|
||||||
|
"execute-command": "$PROJECT_ROOT/deployment/styleguide/deploy-styleguide.sh",
|
||||||
|
"pass-arguments-to-command": [
|
||||||
|
{
|
||||||
|
"source": "string",
|
||||||
|
"name": "$DEPLOY_DIR"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"command-working-directory": "$PROJECT_ROOT",
|
||||||
|
"trigger-rule": {
|
||||||
|
"and": [
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
"type": "payload-hash-sha1",
|
||||||
|
"secret": "$WEBHOOK_GITHUB_SECRET",
|
||||||
|
"parameter": {
|
||||||
|
"source": "header",
|
||||||
|
"name": "X-Hub-Signature"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
"type": "value",
|
||||||
|
"value": "refs/heads/$WEBHOOK_GITHUB_BRANCH",
|
||||||
|
"parameter": {
|
||||||
|
"source": "payload",
|
||||||
|
"name": "ref"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
4
deployment/styleguide/webhook.template
Normal file
4
deployment/styleguide/webhook.template
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
command=webhook
|
||||||
|
command_args="-hooks $PROJECT_ROOT/deployment/styleguide/hooks.json &"
|
||||||
Loading…
x
Reference in New Issue
Block a user