diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f24811 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +parts +prime +stage +snap/.snapcraft diff --git a/snap/scripts/run.sh b/snap/scripts/run.sh new file mode 100755 index 0000000..91766e3 --- /dev/null +++ b/snap/scripts/run.sh @@ -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 $@ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..e6f7b4b --- /dev/null +++ b/snap/snapcraft.yaml @@ -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