mirror of
https://github.com/IT4Change/IT4C.dev.git
synced 2025-12-13 09:25:49 +00:00
Merge branch 'master' into 16-devops-evaluate-theme-hope
This commit is contained in:
commit
5e1bb9da31
29
.github/webhooks/deploy.sh
vendored
Executable file
29
.github/webhooks/deploy.sh
vendored
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Find current directory & configure paths
|
||||
SCRIPT_PATH=$(realpath $0)
|
||||
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
|
||||
PROJECT_ROOT=$SCRIPT_DIR/../..
|
||||
DEPLOY_DIR=$1
|
||||
BUILD_DIR=$PROJECT_ROOT/docs/.vuepress/dist
|
||||
|
||||
# assuming you are already on the right branch
|
||||
git pull -ff
|
||||
|
||||
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
|
||||
rm -R $BUILD_DIR
|
||||
npm run build
|
||||
|
||||
# Copy files and Sym link
|
||||
mkdir $DEPLOY_DIR_REF/
|
||||
cp -r $BUILD_DIR/* $DEPLOY_DIR_REF/
|
||||
ln -sf $DEPLOY_DIR_REF $DEPLOY_DIR
|
||||
37
.github/webhooks/hooks.json.template
vendored
Normal file
37
.github/webhooks/hooks.json.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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
4
.github/webhooks/webhook.template
vendored
Normal file
4
.github/webhooks/webhook.template
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
command=webhook
|
||||
command_args="-hooks $PROJECT_ROOT/.github/webhooks/hooks.json &"
|
||||
1
.github/workflows/lint_pr.yml
vendored
1
.github/workflows/lint_pr.yml
vendored
@ -1,7 +1,6 @@
|
||||
name: "lint pull request CI"
|
||||
|
||||
on:
|
||||
#pull_request:
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
|
||||
2
.github/workflows/test-build.yml
vendored
2
.github/workflows/test-build.yml
vendored
@ -1,6 +1,6 @@
|
||||
name: build test CI
|
||||
|
||||
on: pull_request_target
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
|
||||
2
.github/workflows/test-lint.yml
vendored
2
.github/workflows/test-lint.yml
vendored
@ -1,6 +1,6 @@
|
||||
name: lint test CI
|
||||
|
||||
on: pull_request_target
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/node_modules/
|
||||
/docs/.vuepress/dist/
|
||||
/.github/webhooks/hooks.json
|
||||
|
||||
50
README.md
50
README.md
@ -42,6 +42,56 @@ Run the tests to ensure everything is working as expected
|
||||
npm test
|
||||
```
|
||||
|
||||
## Deploy
|
||||
|
||||
You can use the webhook template `webhook.conf.template` and the `deploy.sh` script in `.github/webhooks/` for an automatic deployment from a (github) webhook.
|
||||
|
||||
For this to work follow these steps (using alpine):
|
||||
```bash
|
||||
apk add webhook
|
||||
cp .github/webhooks/hooks.json.template .github/webhooks/hooks.json
|
||||
vi .github/webhooks/hooks.json
|
||||
# adjust content of .github/webhooks/hooks.json
|
||||
# replace all variables accordingly
|
||||
|
||||
# copy webhook service file
|
||||
cp .github/webhooks/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
|
||||
|
||||
vi /etc/nginx/http.d/default.conf
|
||||
# adjust the nginx config
|
||||
# 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;
|
||||
#
|
||||
# #access_log $LOG_PATH/nginx-access.hooks.log hooks_log;
|
||||
# #error_log $LOG_PATH/nginx-error.backend.hook.log warn;
|
||||
# }
|
||||
```
|
||||
|
||||
For the github webhook configure the following:
|
||||
|
||||
| Field | Value |
|
||||
|------------------------------------------------------|-------------------------------|
|
||||
| Payload URL | https://it4c.dev/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] |
|
||||
|
||||
## How it works
|
||||
|
||||
This repository utilizes `vuepress-deploy` to automatically deploy the current `master` branch to github pages.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user