Added presencia deploy
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
FROM klakegg/hugo:alpine-ci
|
FROM klakegg/hugo:alpine-ci
|
||||||
|
|
||||||
# Install git and ssh
|
# Install git and ssh
|
||||||
RUN apk add --no-cache git openssh rsync
|
RUN apk add --no-cache git openssh rsync jq curl
|
||||||
|
|
||||||
# Install python/pip
|
# Install python/pip
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|||||||
4
main.py
4
main.py
@@ -37,7 +37,6 @@ def deploy(user, repo):
|
|||||||
except Exception:
|
except Exception:
|
||||||
response = "Internal Error"
|
response = "Internal Error"
|
||||||
status = 500
|
status = 500
|
||||||
raise
|
|
||||||
return flask.Response(response, status=status)
|
return flask.Response(response, status=status)
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +52,8 @@ def _deploy(user, repo):
|
|||||||
raise HttpError(400, f"Configuration not found for {user}/{repo}")
|
raise HttpError(400, f"Configuration not found for {user}/{repo}")
|
||||||
|
|
||||||
secret = config['secret'].encode('utf-8')
|
secret = config['secret'].encode('utf-8')
|
||||||
signature = hmac.new(secret, flask.request.data, hashlib.sha256).hexdigest()
|
signature = hmac.new(secret, flask.request.data,
|
||||||
|
hashlib.sha256).hexdigest()
|
||||||
h_signature = flask.request.headers.get('X-Gitea-Signature')
|
h_signature = flask.request.headers.get('X-Gitea-Signature')
|
||||||
|
|
||||||
if h_signature != signature:
|
if h_signature != signature:
|
||||||
|
|||||||
17
scripts/deploy_presencia.sh
Normal file
17
scripts/deploy_presencia.sh
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
echo "Deploying for $GIT_REPO_URL"
|
||||||
|
|
||||||
|
CONTENT_DIR=$(mktemp -d -t ci-XXXXXXXXXX)
|
||||||
|
echo "Working directory: ${CONTENT_DIR}"
|
||||||
|
mkdir -p ${CONTENT_DIR}
|
||||||
|
|
||||||
|
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -i ${GIT_SSH_ID_FILE}" git clone --recurse-submodules ${GIT_REPO_URL} ${CONTENT_DIR}
|
||||||
|
|
||||||
|
cd ${CONTENT_DIR}
|
||||||
|
./deploy/publish.sh
|
||||||
|
|
||||||
|
curl $NOMAD_ADDR/v1/job/$JOB_NAME | jq '.TaskGroups[0].Count = 0 | {"Job": .}' | curl -X POST -d @- $NOMAD_ADDR/v1/job/$JOB_NAME
|
||||||
|
sleep 5
|
||||||
|
curl $NOMAD_ADDR/v1/job/$JOB_NAME | jq '.TaskGroups[0].Count = 1 | {"Job": .}' | curl -X POST -d @- $NOMAD_ADDR/v1/job/$JOB_NAME
|
||||||
Reference in New Issue
Block a user