Skip to content

Commit

Permalink
Add a CI step that comments on PRs included in a new release (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
epwalsh authored Jan 9, 2025
1 parent 74c8bc4 commit eaf811e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,7 @@ jobs:
prerelease: ${{ contains(env.TAG, 'rc') }}
files: |
dist/*
- name: Add PR comments on release
run: |
./scripts/add_pr_comments_on_release.sh
29 changes: 29 additions & 0 deletions scripts/add_pr_comments_on_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -e

repo_url=https://github.com/allenai/beaker-gantry
tags=$(git tag -l --sort=-version:refname 'v*' | head -n 2)
current_tag=$(echo "$tags" | head -n 1)
last_tag=$(echo "$tags" | tail -n 1)

echo "Current release: $current_tag"
echo "Last release: $last_tag"

if [ -z "$last_tag" ]; then
echo "No previous release, nothing to do"
exit 0;
fi

commits_since_last_release=$(git log "${last_tag}..${current_tag}" --format=format:%H)

echo "Commits/PRs since last release:"
for commit in $commits_since_last_release; do
pr_number=$(gh pr list --search "$commit" --state merged --json number --jq '.[].number')
if [ -z "$pr_number" ]; then
echo "$commit"
else
echo "$commit (PR #$pr_number)"
gh pr comment "$pr_number" --body "This PR has been released in [${current_tag}](${repo_url}/releases/tag/${current_tag})."
fi
done

0 comments on commit eaf811e

Please sign in to comment.