Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion .github/workflows/pr-updated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,62 @@ 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 new commits from this push
id: format-commits
uses: actions/github-script@v7
with:
result-encoding: string
script: |
// Get the before and after SHAs from the push event
const before = context.payload.before;
const after = context.payload.after || context.payload.pull_request.head.sha;

console.log(`Comparing commits: ${before}...${after}`);

// Compare commits to get only the new ones from this push
const { data: comparison } = await github.rest.repos.compareCommits({
owner: context.repo.owner,
repo: context.repo.repo,
base: before,
head: after
});

const newCommits = comparison.commits;

if (newCommits.length === 0) {
return 'No new commits in this push';
}

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})`;
}).join('\n');

const count = newCommits.length;
return `${count} new 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: "🔄 Pull Request Updated\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: |
🔄 Pull Request Updated

📝 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 }}

📦 Recent Commits:
${{ needs.get-commits.outputs.commits }}

🔗 Link: ${{ github.event.pull_request.html_url }}