Skip to content

Automatic CI/CD

Graft Hook is primarily used to enable automated deployments triggered by external services like GitHub Actions.

Graft Hook is automatically configured when you choose a Git-based deployment mode during graft init or via graft mode.

If Graft Hook is not yet installed on your server, Graft will:

  1. Detect its absence.
  2. Prompt you for a webhook domain (e.g., hook.yourdomain.com).
  3. Automatically deploy and configure it with SSL via Traefik.

The Graft Hook expects a JSON payload containing metadata about the deployment. This structure allows the hook to correlate the incoming request with your project settings on the server.

ParameterTypeDescription
projectStringThe normalized name of your Graft project.
repositoryStringThe name of your source repository.
tokenStringA short-lived security token (like secrets.GITHUB_TOKEN) provided by the CI/CD runner.
userStringThe user or actor triggering the deployment (e.g., GitHub username).
typeStringThe deployment type, typically image for GHCR/DockerHub or repo for server builds.
registryStringThe container registry being used (e.g., ghcr.io, docker.io, registry.gitlab.com).

Graft Hook is platform-agnostic and can be triggered from anywhere (GitHub Actions, GitLab CI, Bitbucket Pipelines, or even a local cURL command) by sending a POST request to your hook endpoint.

Use this structure to build your integration:

Terminal window
curl -X POST https://your-hook-domain.com/webhook \
-H "Content-Type: application/json" \
-d '{
"project": "your-project-name",
"repository": "your-repo-name",
"token": "your-runner-token",
"user": "actor-name",
"type": "image/repo",
"registry": "ghcr.io" # or docker.io, registry.gitlab.com, etc.
}'

If your project is named your-project and your hook is at webhook.yourdomain.com:

Terminal window
curl -X POST https://webhook.yourdomain.com/webhook \
-H "Content-Type: application/json" \
-d '{
"project": "your-project",
"repository": "${{ github.event.repository.name }}",
"token": "${{ secrets.GITHUB_TOKEN }}",
"user": "${{ github.actor }}",
"type": "image",
"registry": "ghcr.io"
}'

If your project is on GitLab and your hook is at webhook.yourdomain.com:

deploy:
script:
- |
curl -X POST https://webhook.yourdomain.com/webhook \
-H "Content-Type: application/json" \
-d "{
\"project\": \"your-project\",
\"repository\": \"$CI_PROJECT_NAME\",
\"token\": \"$CI_JOB_TOKEN\",
\"user\": \"$GITLAB_USER_LOGIN\",
\"type\": \"image\",
\"registry\": \"registry.gitlab.com\"
}"

Graft automatically generates a GitHub Actions workflow template in .github/workflows/graft-deploy.yml when using Git modes. This template uses the request structure shown above to notify your server of new builds.

You can monitor the activities of the Graft Hook in real-time to debug deployment issues:

Terminal window
graft hook logs

The logs will show authentication attempts, project matching, and the status of concurrent deployment tasks.