Skip to content
  • English Deutsch

benjamin-abt.com

Performance is a feature | Cloud - AI - Azure - .NET - Sustainability

  • Home
  • Blog
  • Portfolio
    • Overview
    • Workshops & Training
    • Publications
  • Contact
  • Home
  • Blog

Automate Pull Request Comments with GitHub Actions

Automate Pull Request Comments with GitHub Actions
January 4, 2026 2 min read BEN ABT
GitHub Actions DevOps Automation Cloudflare

When working with Pull Requests (PRs) in GitHub, it is often helpful to provide immediate feedback or relevant information directly in the conversation view. Whether it is a deployment preview URL, code coverage results or a summary of changes, having this information automatically posted as a comment saves time and improves collaboration.

In this post, I will show you how to use GitHub Actions to automatically add or update a comment on a PR. We will use the marocchino/sticky-pull-request-comment action, which is excellent for maintaining a single, up-to-date comment rather than spamming the PR with new comments for every run.

The Use Case: Cloudflare Preview URLs

A common scenario is deploying a preview version of your site for every Pull Request. Services like Cloudflare Pages generate a unique URL for each deployment. To make it easy for reviewers to access this preview, we can post the URL directly to the PR.

The Workflow

We will use the marocchino/sticky-pull-request-comment action. This action allows you to specify a header, which acts as a unique identifier. If a comment with that header already exists, the action updates it; otherwise, it creates a new one.

Here is an example configuration that posts a Cloudflare deployment URL:

YAML
 1- name: Add/Update PR Comment
 2  uses: marocchino/sticky-pull-request-comment@v2
 3  if: github.event_name == 'pull_request'
 4  with:
 5    header: cloudflare-preview
 6    message: |
 7      ### ✅ Deploy Complete!
 8      
 9      |  Name | Link |
10      |---------------------------------|------------------------|
11      | <span aria-hidden="true">🔨</span> Latest Commit | ${{ github.sha }} |
12      | <span aria-hidden="true">😎</span> Deployment URL | [${{ steps.cloudflare.outputs.deployment-url }}](${{ steps.cloudflare.outputs.deployment-url }}) |

Key Components

  1. if: github.event_name == 'pull_request': This ensures the step only runs for Pull Request events. It prevents the action from failing or running unnecessarily on push events to the main branch.

  2. header: cloudflare-preview: This is the crucial part for the “sticky” behavior. The action searches for a comment with this hidden header. This ensures that subsequent runs update the existing comment instead of creating a new one, keeping the PR conversation clean.

  3. message: This is the content of the comment. It supports Markdown, so you can format it with tables, links and headers. In the example above, we create a neat table displaying the commit SHA and the clickable deployment URL.

Conclusion

Automating PR comments is a simple yet powerful way to enhance your development workflow. By providing relevant context directly in the PR, you reduce friction for reviewers and ensure that important information like preview URLs is always accessible and up-to-date.

Related articles

Cloudflare Workers with wrangler.toml: Preview URLs, production routes and SEO-safe SPA handling

May 10, 2026 - 9 min read

Cloudflare Workers with wrangler.toml: Preview URLs, production routes and SEO-safe SPA handling

Cloudflare Workers can separate production and preview traffic cleanly without sacrificing canonical URL control. For search visibility, …

Scheduled Builds for Cloudflare Deployments with GitHub Actions

Jul 14, 2025 - 4 min read

Scheduled Builds for Cloudflare Deployments with GitHub Actions

Static site generators like Hugo do not have a built-in mechanism to automatically publish content–such as blog posts–at a specific time. If …

Serve SPAs correctly on Cloudflare Workers

Jan 5, 2026 - 2 min read

Serve SPAs correctly on Cloudflare Workers

Single Page Applications like React expect the server to always return index.html and let the client-side router take over. On Cloudflare …


BEN ABT

BEN ABT

Ben is Chief Engineering Officer and Principal Software Engineer at Medialesson.de, with a strong focus on .NET and Microsoft Azure. In his professional role, he designs and builds highly scalable platforms for hybrid and cloud-based scenarios. He also advises companies and C-levels on migrating to the sovereign cloud.

He runs myCSharp.de, the largest and most active German-speaking C# community forum, actively contributes to both his own and external open-source projects and regularly shares his knowledge through his blog, at community events, conferences and as a writer for technical magazines.

Let's Work Together

Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

New Platforms

Modernization

Training & Consulting

Contact Me
X Facebook LinkedIn WhatsApp
Back Next Blog Post

Open for work!

Contact Me
BEN ABT BEN ABT Software Engineer · Microsoft MVP Passionate about .NET, Azure, performance optimization and sustainable software engineering.

Medialesson GmbH Logo

Microsoft MVP Logo

Recent posts

View all
Production Rate Limiting in ASP.NET Core

Production Rate Limiting in ASP.NET Core

Nov 3, 2026
The Big Decimal Bugfix with .NET 11

The Big Decimal Bugfix with .NET 11

Nov 2, 2026
Distroless, Chiseled or Alpine: Choosing a .NET Base Image

Distroless, Chiseled or Alpine: Choosing a .NET Base Image

Oct 27, 2026
Stop Using nginx as Your Default Static File Server in Docker

Stop Using nginx as Your Default Static File Server in …

Oct 24, 2026
Containerizing .NET in 2026 Without a Dockerfile

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026

Tags

.NET (195) Csharp (99) ASP.NET Core (49) Azure (41) DevOps (17) Docker (15) Microsoft (14) EF Core (11) Microsoft MVP (11) Security (11) AI (10) GitHub (10) GitHub Copilot (10) ASP.NET (9) Synology (9) .NET 11 (8) Architecture (8) Raspberry (8) Azure Functions (7) Cloudflare (7)
benjamin-abt.com

About BEN

Benjamin Abt is a Software Engineer, Platform Architect and Microsoft MVP specializing in .NET, Azure, cloud architecture, performance optimization and sustainable software development.

Connect

  • Follow me on GitHub
  • Follow me on LinkedIn
  • Follow me on Mastodon
  • Microsoft MVP profile
  • Follow SchwabenCode on GitHub
  • Follow me on X

Quick Links

  • Portfolio
  • Blog
  • Workshops & Training
  • Publications
  • Get in Touch
  • Sitemap
Open for Work

© Copyright Benjamin Abt & SchwabenCode | 2011 - 2026

Content licensed under CC BY 4.0 unless otherwise noted.

  • Impressum
  • Privacy
  • Contact