Skip to content

Commit fa054a4

Browse files
authored
chore: Add release author to SDK notification payload (#865)
2 parents 9306051 + 7496350 commit fa054a4

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

.github/workflows/notify-sdk.yaml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,45 @@ jobs:
99
name: Trigger SDK update workflow
1010
runs-on: ubuntu-latest
1111
steps:
12+
- name: Find PR merger
13+
id: release_author
14+
env:
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
run: |
17+
TAG="${{ github.event.release.tag_name }}"
18+
REPO="${{ github.repository }}"
19+
20+
# Get the object the tag points to
21+
REF_INFO=$(gh api "repos/$REPO/git/ref/tags/$TAG" --jq '.object | "\(.sha) \(.type)"')
22+
TAG_SHA=$(echo "$REF_INFO" | cut -d' ' -f1)
23+
TAG_TYPE=$(echo "$REF_INFO" | cut -d' ' -f2)
24+
25+
# Dereference annotated tag to get commit SHA
26+
if [ "$TAG_TYPE" = "tag" ]; then
27+
COMMIT_SHA=$(gh api "repos/$REPO/git/tags/$TAG_SHA" --jq '.object.sha')
28+
else
29+
COMMIT_SHA="$TAG_SHA"
30+
fi
31+
32+
# Get parent of the release commit (skip chore(release) by bot)
33+
PARENT_SHA=$(gh api "repos/$REPO/commits/$COMMIT_SHA" --jq '.parents[0].sha // empty')
34+
35+
AUTHOR=""
36+
if [ -n "$PARENT_SHA" ]; then
37+
AUTHOR=$(gh api "repos/$REPO/commits/$PARENT_SHA/pulls" --jq '.[0].user.login // empty' 2>/dev/null || echo "")
38+
fi
39+
40+
echo "author=$AUTHOR" >> $GITHUB_OUTPUT
41+
echo "Release author: ${AUTHOR:-unknown}"
42+
1243
- name: Trigger tycho-protocol-sdk update workflow
1344
run: |
1445
curl -X POST \
1546
-H "Accept: application/vnd.github.v3+json" \
1647
-H "Authorization: token ${{ secrets.SDK_REPO_DISPATCH_TOKEN }}" \
1748
https://api.github.com/repos/propeller-heads/tycho-protocol-sdk/dispatches \
18-
-d '{"event_type":"tycho-indexer-release","client_payload":{"version":"${{ github.event.release.tag_name }}"}}'
49+
-d '{"event_type":"tycho-indexer-release","client_payload":{"version":"${{ github.event.release.tag_name }}","release_author":"${{ steps.release_author.outputs.author }}"}}'
1950
2051
- name: Log notification
2152
run: |
22-
echo "Notified tycho-protocol-sdk of release ${{ github.event.release.tag_name }}"
53+
echo "Notified tycho-protocol-sdk of release ${{ github.event.release.tag_name }} by ${{ steps.release_author.outputs.author }}"

0 commit comments

Comments
 (0)