Skip to content

Instantly share code, notes, and snippets.

View chrimaho's full-sized avatar

Chris Mahoney chrimaho

View GitHub Profile
#==============================================================================#
# #
# Title: Update from Git #
# Purpose: Automated process for keeping local Dir updated when #
# there is a WebHook call against it. This is useful when #
# configuring a WebHook call on GitHub or GitLab or similar Repo. #
# Author: chrimaho #
# Created: 13/Apr/2022 #
# #
#==============================================================================#
ls
echo "test message" >> test.txt
ls
git add test.txt
git commit --message "test webhook"
git push
docker compose --file ./docker/docker-compose.yml up --detach --build --force-recreate
version: "3.8"
name: <update>
services:
listener:
image: chrimaho/update-from-git
container_name: listener
environment:
- GIT_URL=<update>
- API_ENDPOINT=<optional update>
- REPO_DIR=<update>
# Uninstall old versions
sudo apt-get remove docker docker-engine docker.io containerd runc
# Update the package index
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
<html>
<head>
<style>
table {{border-collapse: collapse;}}
th {{border: 1.5px solid lightgray;}}
td {{border: 0.5px solid lightgray;}}
th, td {{padding: 5px;}}
</style>
</head>
<body>
# Endpoint: Main Endpoint ----
@app.post \
( path=API_ENDPOINT
, summary="API Endpoint for Git to Call"
, description= \
"Basically, it will:<br><br>" +
f"1. `clone`/`pull` repo from: `{GIT_URL}`<br><br>" +
f"2. Save repo to: `{REPO_DIR}`"
, tags=["Main Process"]
, response_class=JSONResponse
# Endpoint: Health Check ----
@app.get \
( path="/api/health"
, summary="Health check"
, description="Check to ensure that the app is healthy and ready to run."
, tags=["App Info"]
, response_class=PlainTextResponse
, responses= \
{ 200: {"content": {"text/plain": {"schema": None}}}
}
# Endpoint: Health Check ----
@app.get \
( path="/api/health"
, summary="Health check"
, description="Check to ensure that the app is healthy and ready to run."
, tags=["App Info"]
, response_class=PlainTextResponse
, responses= \
{ 200: {"content": {"text/plain": {"schema": None}}}
}
# Successful Response: status_code=200 ----
class Success(BaseModel):
Success:str="Response Text"
# Validation Error: status_code=422 ----
class ValidationError(BaseModel):
Message:str="Details about the validation error"
# Server Error: status_code=500 ----
class InternalServerError(BaseModel):