[
  {
    "path": ".github/dependabot.yml",
    "content": "# Set update schedule for GitHub Actions\nversion: 2\nupdates:\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"weekly\"\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: Docker Build\n\n# Controls when the workflow will run\non:\n  workflow_dispatch:\n  push:\n    branches:\n      - 'master'\n    tags:\n      - '*.*.*'\n  pull_request:\n    branches:\n      - 'master'\n\njobs:\n  build-docker-image:\n    runs-on: ubuntu-latest\n    steps:\n      # Get the repository's code\n      - name: Checkout\n        uses: actions/checkout@v6\n\n      # https://github.com/docker/setup-qemu-action\n      - name: Set up QEMU\n        uses: docker/setup-qemu-action@v4\n\n      # https://github.com/docker/setup-buildx-action\n      - name: Set up Docker Buildx\n        id: buildx\n        uses: docker/setup-buildx-action@v4\n\n      # https://github.com/docker/login-action\n      - name: Login to Docker Hub\n        if: github.event_name != 'pull_request'\n        uses: docker/login-action@v4\n        with:\n          username: ${{ secrets.DOCKERHUB_USERNAME }}\n          password: ${{ secrets.DOCKERHUB_TOKEN }}\n\n      # https://github.com/docker/metadata-action\n      - name: Docker meta\n        id: meta_webhook_docker\n        uses: docker/metadata-action@v6\n        with:\n          images: |\n            almir/webhook\n          tags: |\n            type=ref,event=branch\n            type=semver,pattern={{version}}\n\n      # https://github.com/docker/build-push-action\n      - name: Build and push\n        uses: docker/build-push-action@v7\n        with:\n          context: .\n          platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64\n          push: ${{ github.event_name != 'pull_request' }}\n          tags: ${{ steps.meta_webhook_docker.outputs.tags }}\n          labels: ${{ steps.meta_webhook_docker.outputs.labels }}\n"
  },
  {
    "path": "Dockerfile",
    "content": "# Dockerfile for https://github.com/adnanh/webhook\nFROM        golang:alpine AS build\nLABEL       org.opencontainers.image.authors=\"almir@dzinovic.net\"\nWORKDIR     /go/src/github.com/adnanh/webhook\nENV         WEBHOOK_VERSION=2.8.3\nRUN         apk add --update -t build-deps curl libc-dev gcc libgcc\nRUN         curl -L --silent -o webhook.tar.gz https://github.com/adnanh/webhook/archive/${WEBHOOK_VERSION}.tar.gz && \\\n            tar -xzf webhook.tar.gz --strip 1\nRUN         go mod download\nRUN         CGO_ENABLED=0 go build -ldflags=\"-s -w\" -o /usr/local/bin/webhook\n\nFROM        alpine:latest\nRUN         apk --no-cache add ca-certificates tzdata && \\\n            addgroup -g 1000 webhook && \\\n            adduser -D -s /bin/sh -u 1000 -G webhook webhook\nCOPY        --from=build /usr/local/bin/webhook /usr/local/bin/webhook\nWORKDIR     /etc/webhook\nVOLUME      [\"/etc/webhook\"]\nEXPOSE      9000\nUSER        webhook\nENTRYPOINT  [\"/usr/local/bin/webhook\"]\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2016 Almir Dzinovic\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "[Webhook](https://github.com/adnanh/webhook/) Dockerized\n=================\n\n## Running webhook in Docker\nThe 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:\n```shell\ndocker run -d -p 9000:9000 -v /dir/to/hooks/on/host:/etc/webhook --name=webhook \\\n  almir/webhook -verbose -hooks=/etc/webhook/hooks.json -hotreload\n```\n\nAnother method of using this Docker image is to create a simple `Dockerfile`:\n```docker\nFROM almir/webhook\nCOPY hooks.json.example /etc/webhook/hooks.json\n```\n\nThis `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:\n```shell\ndocker run -d -p 9000:9000 --name=webhook my-webhook-image -verbose -hooks=/etc/webhook/hooks.json -hotreload\n```\n\nAdditionally, 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:\n```docker\nFROM almir/webhook\nCOPY hooks.json.example /etc/webhook/hooks.json\nCMD [\"-verbose\", \"-hooks=/etc/webhook/hooks.json\", \"-hotreload\"]\n```\n\nNow, after building your Docker image with `docker build -t my-webhook-image .`, you can start your container by running just:\n```shell\ndocker run -d -p 9000:9000 --name=webhook my-webhook-image\n```\n"
  },
  {
    "path": "auto-update-repo/README.md",
    "content": "### Using this script\n\nAdd `update-repo.sh` script to your `crontab`, like this:\n```shell\n  ./update-repo.sh --user someuser --password somepassword --write-crontab\n```\n\nThis 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.\n"
  },
  {
    "path": "auto-update-repo/update-repo.sh",
    "content": "#!/bin/bash\nset -o pipefail\n\n# Set path to this script\nSCRIPTPATH=\"$(cd \"$(dirname \"${BASH_SOURCE[0]:-$0}\")\" && pwd)\"\n# Get script's name\nSCRIPTNAME=\"${BASH_SOURCE[0]##*/}\"\n\ncheck_and_update() {\n  # Get inside the git repo directory\n  cd \"${SCRIPTPATH}\"/.. || exit 1\n  # Get the branch currently used\n  CURBRANCH=$(git rev-parse --abbrev-ref HEAD)\n  # Get latest updates to the repo\n  git fetch --all && \\\n  git reset --hard origin/\"${CURBRANCH}\"\n\n  # Get latest release of webhook and release used in this repo\n  LATEST_RELEASE=$(curl -sf https://api.github.com/repos/adnanh/webhook/releases/latest | \\\n    jq -r '.tag_name // empty' 2>/dev/null || \\\n    curl -s https://api.github.com/repos/adnanh/webhook/releases/latest | \\\n    grep -o '\"tag_name\": *\"[^\"]*\"' | cut -d'\"' -f4)\n  LOCAL_RELEASE=$(grep \"^ENV.*WEBHOOK_VERSION\" \"${SCRIPTPATH}\"/../Dockerfile | awk -F '=' '{ print $2 }')\n\n  # Compare releases and update Dockerfile in case they differ\n  if [[ \"${LOCAL_RELEASE}\" != \"${LATEST_RELEASE}\" ]] && [[ -n ${LATEST_RELEASE} ]]; then\n    # Update the Dockerfile with new version\n    sed -i \"s/WEBHOOK_VERSION=${LOCAL_RELEASE}/WEBHOOK_VERSION=${LATEST_RELEASE}/g\" \"${SCRIPTPATH}\"/../Dockerfile\n\n    # Commit and push changes\n    git add \"${SCRIPTPATH}\"/../Dockerfile\n    git commit -m \"- bump webhook version to ${LATEST_RELEASE}\"\n\n    # Push and create release if credentials are provided\n    if [[ -n ${GITHUB_USER} ]] && [[ -n ${GITHUB_TOKEN} ]]; then\n      git push origin \"${CURBRANCH}\" && \\\n      curl -sf -X POST -H \"Content-Type: application/json\" \\\n        -H \"Authorization: token ${GITHUB_TOKEN}\" \\\n        -d '{\"tag_name\":\"'\"${LATEST_RELEASE}\"'\",\"target_commitish\":\"'\"${CURBRANCH}\"'\",\"name\":\"webhook '\"${LATEST_RELEASE}\"'\",\"body\":\"Release for webhook version '\"${LATEST_RELEASE}\"'.\",\"draft\":false,\"prerelease\":false}' \\\n        https://api.github.com/repos/\"${GITHUB_USER}\"/docker-webhook/releases\n    else\n      git push origin \"${CURBRANCH}\"\n      echo \"GitHub credentials not provided - skipping release creation\"\n    fi\n\n    echo \"Updated webhook version from ${LOCAL_RELEASE} to ${LATEST_RELEASE}\"\n  else\n    echo \"Webhook version is up to date (${LOCAL_RELEASE})\"\n  fi\n}\n\nargmissing() {\n  echo \"Usage: $0 [--user GITHUB_USERNAME] [--token GITHUB_TOKEN] [--write-crontab]\"\n  echo\n  echo \"Switches:\"\n  echo -e \"\\t--user\\t\\t\\tSpecify GitHub username - optional (required for release creation).\"\n  echo -e \"\\t--token\\t\\t\\tSpecify GitHub personal access token - optional (required for release creation).\"\n  echo -e \"\\t--write-crontab\\t\\tAdd crontab entry for this script - optional.\"\n  echo\n  echo \"Examples:\"\n  echo -e \"\\t$0\"\n  echo -e \"\\t$0 --user someuser --token ghp_sometoken\"\n  echo -e \"\\t$0 --user someuser --token ghp_sometoken --write-crontab\"\n  echo -e \"\\t$0 --write-crontab\"\n  echo\n  echo \"Note: GitHub credentials are only needed for automatic release creation.\"\n  echo \"      The script will still update the Dockerfile without them.\"\n  exit 1\n}\n\n# Parse arguments\nwhile [[ $# -gt 0 ]]; do\n  case $1 in\n    --user)\n      GITHUB_USER=\"$2\"\n      shift 2\n      ;;\n    --token)\n      GITHUB_TOKEN=\"$2\"\n      shift 2\n      ;;\n    --write-crontab)\n      WRITE_CRONTAB=true\n      shift\n      ;;\n    --help|-h)\n      argmissing\n      ;;\n    *)\n      echo \"Unknown option: $1\"\n      argmissing\n      ;;\n  esac\ndone\n\n# Handle crontab creation\nif [[ \"${WRITE_CRONTAB}\" == \"true\" ]]; then\n  if ! crontab -l 2>/dev/null | grep -q \"${SCRIPTNAME}\"; then\n    echo \"Creating crontab entry.\"\n    CRON_CMD=\"${SCRIPTPATH}/${SCRIPTNAME}\"\n    if [[ -n ${GITHUB_USER} ]] && [[ -n ${GITHUB_TOKEN} ]]; then\n      CRON_CMD=\"${CRON_CMD} --user ${GITHUB_USER} --token ${GITHUB_TOKEN}\"\n    fi\n    (crontab -l 2>/dev/null; echo -e \"# Check for webhook releases every five minutes\\n*/5 * * * * ${CRON_CMD} > /dev/null 2>&1\") | crontab -\n    echo \"Crontab entry created successfully.\"\n  else\n    echo \"Crontab entry already exists.\"\n  fi\nfi\n\n# Run the main function\ncheck_and_update\n\nexit 0\n"
  }
]