Add Latest Tag sensor to GitHub integration (#66932)
This commit is contained in:
parent
3cbbf90f23
commit
2d52aca9eb
3 changed files with 31 additions and 0 deletions
|
@ -68,6 +68,18 @@ query ($owner: String!, $repository: String!) {
|
|||
url
|
||||
tag: tagName
|
||||
}
|
||||
refs(
|
||||
first: 1
|
||||
refPrefix: "refs/tags/"
|
||||
orderBy: {field: TAG_COMMIT_DATE, direction: DESC}
|
||||
) {
|
||||
tags: nodes {
|
||||
name
|
||||
target {
|
||||
url: commitUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
|
|
@ -126,6 +126,15 @@ SENSOR_DESCRIPTIONS: tuple[GitHubSensorEntityDescription, ...] = (
|
|||
"number": data["pull_request"]["pull_requests"][0]["number"],
|
||||
},
|
||||
),
|
||||
GitHubSensorEntityDescription(
|
||||
key="latest_tag",
|
||||
name="Latest Tag",
|
||||
avabl_fn=lambda data: data["refs"]["tags"],
|
||||
value_fn=lambda data: data["refs"]["tags"][0]["name"][:255],
|
||||
attr_fn=lambda data: {
|
||||
"url": data["refs"]["tags"][0]["target"]["url"],
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -43,6 +43,16 @@
|
|||
"name": "v1.0.0",
|
||||
"url": "https://github.com/octocat/Hello-World/releases/v1.0.0",
|
||||
"tag": "v1.0.0"
|
||||
},
|
||||
"refs": {
|
||||
"tags": [
|
||||
{
|
||||
"name": "v1.0.0",
|
||||
"target": {
|
||||
"url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue