DEV Community

Mher Poghosyan
Mher Poghosyan

Posted on Originally published at Medium on

GitHub Actions Manual Approval via Telegram


Approval via Telegram

In CI/CD workflows, especially those involving production deployments , an extra layer of approval can be crucial. Using Telegram Manual Approval for GitHub Actions allows workflows to pause until an explicit approval or rejection is given via Telegram. This article walks through setup, configuration, and usage of this approach to ensure controlled and secure deployments.

Why Use Telegram Manual Approval?

GitHub Actions enables automation, but sometimes manual intervention is needed before proceeding with sensitive operations like deployments. With Telegram Manual Approval , you can:

✅ Pause the workflow until an approval or rejection is received.

✅ Grant specific users the ability to approve or reject the workflow.

✅ Enhance security and reduce deployment risks.

✅ Automate approval requests via Telegram messages.

How It Works

  1. When the workflow reaches the telegram-manual-approval step, it sends a customizable message to a specified Telegram chat.
  2. The message includes Approve and Reject buttons.
  3. A user with the appropriate permissions can click on the buttons to either:
  • ✅ Approve: The workflow continues execution.
  • ❌ Reject: The workflow fails and stops.

Setup Guide

1️⃣ Create a Telegram Bot

  • Open Telegram and search for @botfather.
  • Use the command /newbot to create a bot.
  • Save the API token provided by BotFather.

2️⃣ Get Your Telegram Chat ID

  • Use @getmyid_bot in Telegram to retrieve your chat ID.

3️⃣ Store Secrets in GitHub

  • Navigate to GitHub Repository → Settings → Secrets and Variables → Actions.
  • Save:
  • TELEGRAM_KEY → Your bot’s API key.
  • TELEGRAM_CHAT_ID → Your Telegram chat ID.

How to Use the Action in GitHub Actions

Add the following step to your GitHub Actions workflow file (.github/workflows/deploy.yml):

steps:
  - uses: khasanovbi/telegram-manual-approval@v0.0.2
    with:
      telegram-key: ${{ secrets.TELEGRAM_KEY }}
      telegram-chat-id: ${{ vars.TELEGRAM_CHAT_ID }}
      github-to-telegram: |
          githubUsername: telegramUsername
          anotherGitHubUsername: 123456789
      approvers: |
          githubUsername
      super-approvers: |
          anotherGitHubUsername
Enter fullscreen mode Exit fullscreen mode

Explanation of Parameters

  • telegram-key → The Telegram bot token.
  • telegram-chat-id → The chat ID where the approval request is sent.
  • github-to-telegram → Maps GitHub usernames to Telegram usernames or IDs.
  • approvers → GitHub users allowed to approve/reject deployments.
  • super-approvers → Users with elevated privileges (can override settings).

Message Text Customization

You can personalize approval/rejection messages and buttons:

approval-text: "%%actor%% wants to deploy %%github_ref_url%% to production."
approve-button: "✅ Approve"
reject-button: "❌ Reject"
approved-text: "✅ Approved by %%approver%%"
rejected-text: "❌ Rejected by %%approver%%"
Enter fullscreen mode Exit fullscreen mode

Available Template Variables

  • %%actor%% → The user who triggered the workflow.
  • %%approver%% → The user who approved or rejected.
  • %%github_ref_url%% → URL to the GitHub branch/tag.
  • %%workflow_run_url%% → URL to the workflow run.

Example: Deployment Workflow with Approval

name: Release

on:
  workflow_dispatch:
    inputs:
      environment:
        description: 'Environment'
        default: stage
        type: environment
        required: true

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment }}

    steps:
      - uses: khasanovbi/telegram-manual-approval@v0.0.2
        if: inputs.environment == 'prod'
        with:
          telegram-key: '${{ secrets.TELEGRAM_KEY }}'
          telegram-chat-id: '${{ vars.TELEGRAM_CHAT_ID }}'
          github-to-telegram: |
              githubUsername: telegramUsername
              anotherGitHubUsername: 123456789
          approvers: |
              githubUsername
          super-approvers: |
              anotherGitHubUsername

      - name: Run deploy
        run: |
          echo "Deploying..."
Enter fullscreen mode Exit fullscreen mode

What Happens Here?

  1. The workflow is manually triggered (workflow_dispatch).
  2. If the environment is ‘prod’ , the Telegram approval request is sent.
  3. The deployment pauses until an approval is received.
  4. Once approved, the deployment continues (Run deploy).

Final Thoughts

Using Telegram Manual Approval adds an extra layer of security and control to GitHub Actions workflows. This is particularly useful for critical deployments where an extra review step is necessary.

By integrating Telegram approvals, teams can:

✔ Ensure controlled deployments.

✔ Improve team collaboration through chat-based approvals.

✔ Reduce the risk of accidental deployments.

🔹 Try it out and enhance your GitHub CI/CD workflows today! 🚀

Top comments (0)