|
9 | 9 | name: Trigger SDK update workflow |
10 | 10 | runs-on: ubuntu-latest |
11 | 11 | 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 | +
|
12 | 43 | - name: Trigger tycho-protocol-sdk update workflow |
13 | 44 | run: | |
14 | 45 | curl -X POST \ |
15 | 46 | -H "Accept: application/vnd.github.v3+json" \ |
16 | 47 | -H "Authorization: token ${{ secrets.SDK_REPO_DISPATCH_TOKEN }}" \ |
17 | 48 | 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 }}"}}' |
19 | 50 |
|
20 | 51 | - name: Log notification |
21 | 52 | 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