mirror of
https://github.com/IT4Change/IT4C.dev.git
synced 2025-12-13 09:25:49 +00:00
initial blind implementation & documentation of a webhook
This commit is contained in:
parent
142c9e42c9
commit
2d54fb24ca
24
.github/webhooks/deploy.sh
vendored
Executable file
24
.github/webhooks/deploy.sh
vendored
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Find current directory & configure paths
|
||||||
|
SCRIPT_PATH=$(realpath $0)
|
||||||
|
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
|
||||||
|
PROJECT_ROOT=$SCRIPT_DIR/../..
|
||||||
|
DEPLOY_DIR=$i
|
||||||
|
BUILD_DIR=$PROJECT_ROOT/docs/.vuepress/dist
|
||||||
|
GIT_REF=$(git rev-parse --short HEAD)
|
||||||
|
DEPLOY_DIR_REF=$1-$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
|
||||||
|
rm -R $BUILD_DIR
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# Copy files and Sym link
|
||||||
|
cp $BUILD_DIR $DEPLOY_DIR_REF
|
||||||
|
ln -sf $DEPLOY_DIR_REF $DEPLOY_DIR
|
||||||
37
.github/webhooks/webhook.conf.template
vendored
Normal file
37
.github/webhooks/webhook.conf.template
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "github",
|
||||||
|
"execute-command": "$PROJECT_ROOT/.github/webhooks/deploy.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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
12
README.md
12
README.md
@ -42,6 +42,18 @@ Run the tests to ensure everything is working as expected
|
|||||||
npm test
|
npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Deploy
|
||||||
|
|
||||||
|
You can use the webhook template `webhook.conf.template` and the `deploy.sh` script in `.github/webhooks/` to implement an automatic deployment from a (github) webhook.
|
||||||
|
|
||||||
|
To work follow these steps (using alpine):
|
||||||
|
```bash
|
||||||
|
apk add webhook
|
||||||
|
cp .github/webhooks/webhook.conf /etc/webhook.conf
|
||||||
|
# adjust content of /etc/webhook.conf accordingly
|
||||||
|
systemctl enable webhook
|
||||||
|
systemctl start webhook
|
||||||
|
```
|
||||||
## How it works
|
## How it works
|
||||||
|
|
||||||
This repository utilizes `vuepress-deploy` to automatically deploy the current `master` branch to github pages.
|
This repository utilizes `vuepress-deploy` to automatically deploy the current `master` branch to github pages.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user