Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parts
prime
stage
snap/.snapcraft
27 changes: 27 additions & 0 deletions snap/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

if [ ! -f "$SNAP_COMMON/config.json" ]; then
cp "$SNAP/config.json.sample" "$SNAP_COMMON/config.json"
fi

if [ ! -L "$SNAP_COMMON/webhooks.py" ]; then
ln -sf "$SNAP/webhooks.py" "$SNAP_COMMON"
fi

if [ "X$SNAP_ARCH" = "Xamd64" ]; then
ARCH="x86_64-linux-gnu"
elif [ "X$SNAP_ARCH" = "Xarmhf" ]; then
ARCH="arm-linux-gnueabihf"
elif [ "X$SNAP_ARCH" = "Xarm64" ]; then
ARCH="aarch64-linux-gnu"
else
ARCH="$SNAP_ARCH-linux-gnu"
fi

export PATH=$SNAP/usr/bin:$PATH
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$SNAP/usr/lib:$LD_LIBRARY_PATH

cd "$SNAP_COMMON"
mkdir -p hooks

exec env $SNAP/usr/bin/python3 ./webhooks.py $@
35 changes: 35 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: python-github-webhooks
version: git
summary: Simple Python WSGI application to handle Github webhooks
description: |
Simple Python WSGI application to handle Github webhooks

grade: stable
confinement: strict

parts:
python-github-webhooks:
plugin: python
requirements: requirements.txt
source: .
override-build: |
snapcraftctl build
install -m 755 webhooks.py $SNAPCRAFT_PART_INSTALL
install -m 644 config.json.sample $SNAPCRAFT_PART_INSTALL
ln -s python3 $SNAPCRAFT_PART_INSTALL/usr/bin/python || true
stage-packages:
- git

runner:
plugin: dump
source: snap/scripts
organize:
webhooks: bin/run.sh

apps:
python-github-webhooks:
command: ./run.sh
daemon: simple
plugs:
- network
- network-bind