Full Code of almir/docker-webhook for AI

master a829bed69992 cached
7 files
9.4 KB
2.8k tokens
1 requests
Download .txt
Repository: almir/docker-webhook
Branch: master
Commit: a829bed69992
Files: 7
Total size: 9.4 KB

Directory structure:
gitextract_xl9au464/

├── .github/
│   ├── dependabot.yml
│   └── workflows/
│       └── main.yml
├── Dockerfile
├── LICENSE
├── README.md
└── auto-update-repo/
    ├── README.md
    └── update-repo.sh

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/dependabot.yml
================================================
# Set update schedule for GitHub Actions
version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "weekly"


================================================
FILE: .github/workflows/main.yml
================================================
name: Docker Build

# Controls when the workflow will run
on:
  workflow_dispatch:
  push:
    branches:
      - 'master'
    tags:
      - '*.*.*'
  pull_request:
    branches:
      - 'master'

jobs:
  build-docker-image:
    runs-on: ubuntu-latest
    steps:
      # Get the repository's code
      - name: Checkout
        uses: actions/checkout@v6

      # https://github.com/docker/setup-qemu-action
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v4

      # https://github.com/docker/setup-buildx-action
      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v4

      # https://github.com/docker/login-action
      - name: Login to Docker Hub
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v4
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      # https://github.com/docker/metadata-action
      - name: Docker meta
        id: meta_webhook_docker
        uses: docker/metadata-action@v6
        with:
          images: |
            almir/webhook
          tags: |
            type=ref,event=branch
            type=semver,pattern={{version}}

      # https://github.com/docker/build-push-action
      - name: Build and push
        uses: docker/build-push-action@v7
        with:
          context: .
          platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta_webhook_docker.outputs.tags }}
          labels: ${{ steps.meta_webhook_docker.outputs.labels }}


================================================
FILE: Dockerfile
================================================
# Dockerfile for https://github.com/adnanh/webhook
FROM        golang:alpine AS build
LABEL       org.opencontainers.image.authors="almir@dzinovic.net"
WORKDIR     /go/src/github.com/adnanh/webhook
ENV         WEBHOOK_VERSION=2.8.3
RUN         apk add --update -t build-deps curl libc-dev gcc libgcc
RUN         curl -L --silent -o webhook.tar.gz https://github.com/adnanh/webhook/archive/${WEBHOOK_VERSION}.tar.gz && \
            tar -xzf webhook.tar.gz --strip 1
RUN         go mod download
RUN         CGO_ENABLED=0 go build -ldflags="-s -w" -o /usr/local/bin/webhook

FROM        alpine:latest
RUN         apk --no-cache add ca-certificates tzdata && \
            addgroup -g 1000 webhook && \
            adduser -D -s /bin/sh -u 1000 -G webhook webhook
COPY        --from=build /usr/local/bin/webhook /usr/local/bin/webhook
WORKDIR     /etc/webhook
VOLUME      ["/etc/webhook"]
EXPOSE      9000
USER        webhook
ENTRYPOINT  ["/usr/local/bin/webhook"]


================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2016 Almir Dzinovic

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
[Webhook](https://github.com/adnanh/webhook/) Dockerized
=================

## Running webhook in Docker
The simplest usage of [almir/webhook](https://hub.docker.com/r/almir/webhook/) image is for one to host the hooks JSON file on their machine and mount the directory in which those are kept as a volume to the Docker container:
```shell
docker run -d -p 9000:9000 -v /dir/to/hooks/on/host:/etc/webhook --name=webhook \
  almir/webhook -verbose -hooks=/etc/webhook/hooks.json -hotreload
```

Another method of using this Docker image is to create a simple `Dockerfile`:
```docker
FROM almir/webhook
COPY hooks.json.example /etc/webhook/hooks.json
```

This `Dockerfile` and `hooks.json.example` files should be placed inside the same directory. After that run `docker build -t my-webhook-image .` and then start your container:
```shell
docker run -d -p 9000:9000 --name=webhook my-webhook-image -verbose -hooks=/etc/webhook/hooks.json -hotreload
```

Additionally, one can specify the parameters to be passed to [webhook](https://github.com/adnanh/webhook/) in `Dockerfile` simply by adding one more line to the previous example:
```docker
FROM almir/webhook
COPY hooks.json.example /etc/webhook/hooks.json
CMD ["-verbose", "-hooks=/etc/webhook/hooks.json", "-hotreload"]
```

Now, after building your Docker image with `docker build -t my-webhook-image .`, you can start your container by running just:
```shell
docker run -d -p 9000:9000 --name=webhook my-webhook-image
```


================================================
FILE: auto-update-repo/README.md
================================================
### Using this script

Add `update-repo.sh` script to your `crontab`, like this:
```shell
  ./update-repo.sh --user someuser --password somepassword --write-crontab
```

This will add a `crontab` entry for the script to execute every five minutes. In case you're not using `crontab` or you want to change the execution frequency you can always add it manually.


================================================
FILE: auto-update-repo/update-repo.sh
================================================
#!/bin/bash
set -o pipefail

# Set path to this script
SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
# Get script's name
SCRIPTNAME="${BASH_SOURCE[0]##*/}"

check_and_update() {
  # Get inside the git repo directory
  cd "${SCRIPTPATH}"/.. || exit 1
  # Get the branch currently used
  CURBRANCH=$(git rev-parse --abbrev-ref HEAD)
  # Get latest updates to the repo
  git fetch --all && \
  git reset --hard origin/"${CURBRANCH}"

  # Get latest release of webhook and release used in this repo
  LATEST_RELEASE=$(curl -sf https://api.github.com/repos/adnanh/webhook/releases/latest | \
    jq -r '.tag_name // empty' 2>/dev/null || \
    curl -s https://api.github.com/repos/adnanh/webhook/releases/latest | \
    grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4)
  LOCAL_RELEASE=$(grep "^ENV.*WEBHOOK_VERSION" "${SCRIPTPATH}"/../Dockerfile | awk -F '=' '{ print $2 }')

  # Compare releases and update Dockerfile in case they differ
  if [[ "${LOCAL_RELEASE}" != "${LATEST_RELEASE}" ]] && [[ -n ${LATEST_RELEASE} ]]; then
    # Update the Dockerfile with new version
    sed -i "s/WEBHOOK_VERSION=${LOCAL_RELEASE}/WEBHOOK_VERSION=${LATEST_RELEASE}/g" "${SCRIPTPATH}"/../Dockerfile

    # Commit and push changes
    git add "${SCRIPTPATH}"/../Dockerfile
    git commit -m "- bump webhook version to ${LATEST_RELEASE}"

    # Push and create release if credentials are provided
    if [[ -n ${GITHUB_USER} ]] && [[ -n ${GITHUB_TOKEN} ]]; then
      git push origin "${CURBRANCH}" && \
      curl -sf -X POST -H "Content-Type: application/json" \
        -H "Authorization: token ${GITHUB_TOKEN}" \
        -d '{"tag_name":"'"${LATEST_RELEASE}"'","target_commitish":"'"${CURBRANCH}"'","name":"webhook '"${LATEST_RELEASE}"'","body":"Release for webhook version '"${LATEST_RELEASE}"'.","draft":false,"prerelease":false}' \
        https://api.github.com/repos/"${GITHUB_USER}"/docker-webhook/releases
    else
      git push origin "${CURBRANCH}"
      echo "GitHub credentials not provided - skipping release creation"
    fi

    echo "Updated webhook version from ${LOCAL_RELEASE} to ${LATEST_RELEASE}"
  else
    echo "Webhook version is up to date (${LOCAL_RELEASE})"
  fi
}

argmissing() {
  echo "Usage: $0 [--user GITHUB_USERNAME] [--token GITHUB_TOKEN] [--write-crontab]"
  echo
  echo "Switches:"
  echo -e "\t--user\t\t\tSpecify GitHub username - optional (required for release creation)."
  echo -e "\t--token\t\t\tSpecify GitHub personal access token - optional (required for release creation)."
  echo -e "\t--write-crontab\t\tAdd crontab entry for this script - optional."
  echo
  echo "Examples:"
  echo -e "\t$0"
  echo -e "\t$0 --user someuser --token ghp_sometoken"
  echo -e "\t$0 --user someuser --token ghp_sometoken --write-crontab"
  echo -e "\t$0 --write-crontab"
  echo
  echo "Note: GitHub credentials are only needed for automatic release creation."
  echo "      The script will still update the Dockerfile without them."
  exit 1
}

# Parse arguments
while [[ $# -gt 0 ]]; do
  case $1 in
    --user)
      GITHUB_USER="$2"
      shift 2
      ;;
    --token)
      GITHUB_TOKEN="$2"
      shift 2
      ;;
    --write-crontab)
      WRITE_CRONTAB=true
      shift
      ;;
    --help|-h)
      argmissing
      ;;
    *)
      echo "Unknown option: $1"
      argmissing
      ;;
  esac
done

# Handle crontab creation
if [[ "${WRITE_CRONTAB}" == "true" ]]; then
  if ! crontab -l 2>/dev/null | grep -q "${SCRIPTNAME}"; then
    echo "Creating crontab entry."
    CRON_CMD="${SCRIPTPATH}/${SCRIPTNAME}"
    if [[ -n ${GITHUB_USER} ]] && [[ -n ${GITHUB_TOKEN} ]]; then
      CRON_CMD="${CRON_CMD} --user ${GITHUB_USER} --token ${GITHUB_TOKEN}"
    fi
    (crontab -l 2>/dev/null; echo -e "# Check for webhook releases every five minutes\n*/5 * * * * ${CRON_CMD} > /dev/null 2>&1") | crontab -
    echo "Crontab entry created successfully."
  else
    echo "Crontab entry already exists."
  fi
fi

# Run the main function
check_and_update

exit 0
Download .txt
gitextract_xl9au464/

├── .github/
│   ├── dependabot.yml
│   └── workflows/
│       └── main.yml
├── Dockerfile
├── LICENSE
├── README.md
└── auto-update-repo/
    ├── README.md
    └── update-repo.sh
Condensed preview — 7 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (10K chars).
[
  {
    "path": ".github/dependabot.yml",
    "chars": 159,
    "preview": "# Set update schedule for GitHub Actions\nversion: 2\nupdates:\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "chars": 1645,
    "preview": "name: Docker Build\n\n# Controls when the workflow will run\non:\n  workflow_dispatch:\n  push:\n    branches:\n      - 'master"
  },
  {
    "path": "Dockerfile",
    "chars": 962,
    "preview": "# Dockerfile for https://github.com/adnanh/webhook\nFROM        golang:alpine AS build\nLABEL       org.opencontainers.ima"
  },
  {
    "path": "LICENSE",
    "chars": 1071,
    "preview": "MIT License\n\nCopyright (c) 2016 Almir Dzinovic\n\nPermission is hereby granted, free of charge, to any person obtaining a "
  },
  {
    "path": "README.md",
    "chars": 1479,
    "preview": "[Webhook](https://github.com/adnanh/webhook/) Dockerized\n=================\n\n## Running webhook in Docker\nThe simplest us"
  },
  {
    "path": "auto-update-repo/README.md",
    "chars": 361,
    "preview": "### Using this script\n\nAdd `update-repo.sh` script to your `crontab`, like this:\n```shell\n  ./update-repo.sh --user some"
  },
  {
    "path": "auto-update-repo/update-repo.sh",
    "chars": 3989,
    "preview": "#!/bin/bash\nset -o pipefail\n\n# Set path to this script\nSCRIPTPATH=\"$(cd \"$(dirname \"${BASH_SOURCE[0]:-$0}\")\" && pwd)\"\n# "
  }
]

About this extraction

This page contains the full source code of the almir/docker-webhook GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 7 files (9.4 KB), approximately 2.8k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!