id: github-release-download-milestone-digest
namespace: company.devops
inputs:
- id: github_owner
type: STRING
displayName: GitHub Organization / Owner
defaults: "kestra-io"
description: GitHub organization or username owning the target repository.
- id: github_repository
type: STRING
displayName: GitHub Repository
defaults: "kestra"
description: GitHub repository slug to inspect for release binary downloads.
- id: release_batch_limit
type: INT
displayName: Release Batch Limit
defaults: 10
description: Number of recent published releases to inspect for asset download
statistics.
- id: min_downloads_threshold
type: INT
displayName: Minimum Download Threshold for Digest
defaults: 1
description: Minimum aggregated asset downloads across inspected releases
required to dispatch a digest.
triggers:
- id: weekly_release_digest_schedule
type: io.kestra.plugin.core.trigger.Schedule
description: Weekly adoption digest dispatched every Monday at 09:00 UTC.
Shipped disabled by default.
cron: "0 9 * * 1"
disabled: true
tasks:
- id: fetch_release_assets
type: io.kestra.plugin.graphql.Request
description: Query GitHub GraphQL API for recent releases and asset download metrics.
uri: "https://api.github.com/graphql"
headers:
Authorization: "Bearer {{ secret('GITHUB_TOKEN') }}"
Content-Type: "application/json"
User-Agent: "Kestra-GitHub-Release-Digest/1.0"
failOnGraphQLErrors: false
query: |
query ($owner: String!, $name: String!, $limit: Int!) {
repository(owner: $owner, name: $name) {
releases(first: $limit, orderBy: {field: CREATED_AT, direction: DESC}) {
nodes {
tagName
name
isDraft
isPrerelease
publishedAt
releaseAssets(first: 20) {
nodes {
name
downloadCount
size
contentType
}
}
}
}
}
}
variables:
owner: "{{ inputs.github_owner }}"
name: "{{ inputs.github_repository }}"
limit: "{{ inputs.release_batch_limit }}"
- id: aggregate_download_metrics
type: io.kestra.plugin.scripts.python.Script
description: Compute aggregate download milestones, top binary assets, and
format digest markdown.
containerImage: python:3.11-slim
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
env:
RESPONSE_BODY: "{{ outputs.fetch_release_assets.body }}"
REPO_OWNER: "{{ inputs.github_owner }}"
REPO_NAME: "{{ inputs.github_repository }}"
script: |
import os
import json
from kestra import Kestra
raw_data = os.environ.get("RESPONSE_BODY", "{}")
repo_owner = os.environ.get("REPO_OWNER", "")
repo_name = os.environ.get("REPO_NAME", "")
try:
data = json.loads(raw_data)
except Exception:
data = {}
releases = data.get("data", {}).get("repository", {}).get("releases", {}).get("nodes", [])
total_downloads = 0
release_summaries = []
top_asset_name = "None"
top_asset_count = 0
for rel in releases:
if rel.get("isDraft"):
continue
tag = rel.get("tagName", "unknown")
assets = rel.get("releaseAssets", {}).get("nodes", [])
rel_total = sum(asset.get("downloadCount", 0) for asset in assets)
total_downloads += rel_total
for asset in assets:
count = asset.get("downloadCount", 0)
if count > top_asset_count:
top_asset_count = count
top_asset_name = f"{tag}: {asset.get('name')}"
release_summaries.append({
"tag": tag,
"published_at": rel.get("publishedAt", "N/A"),
"downloads": rel_total,
"asset_count": len(assets)
})
Kestra.outputs({
"total_downloads": total_downloads,
"release_count": len(release_summaries),
"top_asset_name": top_asset_name,
"top_asset_downloads": top_asset_count,
"summary_markdown": f"Repository *{repo_owner}/{repo_name}* reached *{total_downloads:,}* binary asset downloads across {len(release_summaries)} recent releases. Top asset: `{top_asset_name}` ({top_asset_count:,} downloads)."
})
- id: check_digest_condition
type: io.kestra.plugin.core.flow.If
description: Evaluate whether aggregated binary downloads meet the alert threshold.
condition: "{{ outputs.aggregate_download_metrics.vars.total_downloads >=
inputs.min_downloads_threshold }}"
then:
- id: send_slack_digest
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Dispatch release binary adoption digest to developer relations and
product channels in Slack.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#devrel-product-metrics",
"username": "Kestra GitHub Release Sentinel",
"icon_emoji": ":package:",
"attachments": [
{
"color": "#36a64f",
"title": "GitHub Release Download Adoption Digest: {{ inputs.github_owner }}/{{ inputs.github_repository }}",
"title_link": "https://github.com/{{ inputs.github_owner }}/{{ inputs.github_repository }}/releases",
"text": "{{ outputs.aggregate_download_metrics.vars.summary_markdown }}",
"fields": [
{
"title": "Total Asset Downloads",
"value": "{{ outputs.aggregate_download_metrics.vars.total_downloads }}",
"short": true
},
{
"title": "Inspected Releases",
"value": "{{ outputs.aggregate_download_metrics.vars.release_count }}",
"short": true
},
{
"title": "Most Popular Binary",
"value": "`{{ outputs.aggregate_download_metrics.vars.top_asset_name }}` ({{ outputs.aggregate_download_metrics.vars.top_asset_downloads }} downloads)",
"short": false
}
],
"footer": "Kestra DevRel Automation",
"ts": "{{ now() | date('X') }}"
}
]
}
errors:
- id: send_failure_alert
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Dispatch critical alert if GitHub GraphQL query or metrics
aggregation fails.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#devops-alerts",
"username": "Kestra GitHub Sentinel Alert",
"icon_emoji": ":rotating_light:",
"attachments": [
{
"color": "#dc3545",
"title": "GitHub Release Download Sentinel Failure",
"text": "Execution *{{ execution.id }}* failed during release asset download metrics collection for repository *{{ inputs.github_owner }}/{{ inputs.github_repository }}*.",
"fields": [
{
"title": "Flow ID",
"value": "{{ flow.id }}",
"short": true
},
{
"title": "Namespace",
"value": "{{ flow.namespace }}",
"short": true
}
],
"footer": "Kestra Error Watchdog",
"ts": "{{ now() | date('X') }}"
}
]
}