From 3896d39aff48b3b1c1cdaf73413b65b9cee63939 Mon Sep 17 00:00:00 2001 From: Domen Gabrovsek Date: Tue, 27 Jan 2026 09:18:50 +0100 Subject: [PATCH] feat: add commit details on pr open --- .github/workflows/pr-opened.yml | 45 +++++++++++++++++++++++++++++++- .github/workflows/pr-updated.yml | 3 +-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-opened.yml b/.github/workflows/pr-opened.yml index a806417..a1ecaa1 100644 --- a/.github/workflows/pr-opened.yml +++ b/.github/workflows/pr-opened.yml @@ -18,9 +18,52 @@ on: description: 'Telegram chat ID to send notifications to' jobs: + get-commits: + runs-on: ubuntu-latest + outputs: + commits: ${{ steps.format-commits.outputs.result }} + steps: + - name: Get commits from PR + id: format-commits + uses: actions/github-script@v7 + with: + result-encoding: string + script: | + // Get commits from the PR + const { data: commits } = await github.rest.pulls.listCommits({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number + }); + + if (commits.length === 0) { + return 'No commits in this PR'; + } + + const commitList = commits.map(commit => { + const message = commit.commit.message.split('\n')[0]; // First line only + const sha = commit.sha.substring(0, 7); + return `• ${sha} - ${message}`; + }).join('\n'); + + const count = commits.length; + return `${count} commit${count !== 1 ? 's' : ''}:\n${commitList}`; + notify: + needs: get-commits uses: domengabrovsek/github-actions/.github/workflows/send-telegram-message.yml@master with: api_url: ${{ inputs.api_url }} chat_id: ${{ inputs.chat_id }} - message: "šŸš€ New Pull Request Opened\n\nšŸ“ Title: ${{ github.event.pull_request.title }}\nšŸ‘¤ Author: ${{ github.event.pull_request.user.login }}\n🌿 Branch: `${{ github.event.pull_request.head.ref }}` → `${{ github.event.pull_request.base.ref }}`\nšŸ”— Link: ${{ github.event.pull_request.html_url }}\nšŸ“Š Repository: ${{ github.repository }}" + message: | + šŸš€ New Pull Request Opened + + šŸ“ Title: ${{ github.event.pull_request.title }} + šŸ‘¤ Author: ${{ github.event.pull_request.user.login }} + 🌿 Branch: `${{ github.event.pull_request.head.ref }}` → `${{ github.event.pull_request.base.ref }}` + šŸ“Š Repository: ${{ github.repository }} + + šŸ“¦ Commits: + ${{ needs.get-commits.outputs.commits }} + + šŸ”— Link: ${{ github.event.pull_request.html_url }} diff --git a/.github/workflows/pr-updated.yml b/.github/workflows/pr-updated.yml index aa3a730..92c4eb1 100644 --- a/.github/workflows/pr-updated.yml +++ b/.github/workflows/pr-updated.yml @@ -52,8 +52,7 @@ jobs: const commitList = newCommits.map(commit => { const message = commit.commit.message.split('\n')[0]; // First line only const sha = commit.sha.substring(0, 7); - const author = commit.commit.author.name; - return `• ${sha} - ${message} (${author})`; + return `• ${sha} - ${message}`; }).join('\n'); const count = newCommits.length;