-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
423e33d
commit 57b9ff5
Showing
7 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class WebhooksConfig(AppConfig): | ||
name = 'apps.webhooks' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.urls import path | ||
|
||
from . import views | ||
|
||
app_name = 'webhooks' | ||
|
||
urlpatterns = [ | ||
path('pull/', views.pull_repo, name='pull'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import git | ||
from django.http import HttpResponse | ||
from django.conf import settings | ||
from http import HTTPStatus | ||
|
||
|
||
def pull_repo(request): | ||
"""Get secret key, and pull repo to get changes from GitHub.""" | ||
secret = request.headers.get('X-Hub-Signature') | ||
if request.method == 'POST' and secret == settings.SECRET_KEY: | ||
repo = git.Repo('/home/momonline/hmom3') | ||
origin = repo.remotes.origin | ||
origin.pull() | ||
return HttpResponse('Updated.', status=HTTPStatus.OK) | ||
return HttpResponse('Wrong event.', status=HTTPStatus.BAD_REQUEST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters