Skip to main content

Integrating with External Services

1. Using Slack Notifications

Property Value Description
slack-webhook-url https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX URL of the Slack webhook integration
channel #github-actions Slack channel to post the message to
username GitHub Actions Username to display in Slack
icon_emoji :robot_face: Emoji to use as the icon in Slack

Example: Slack Notification Configuration

name: Slack Notification
on:
  workflow_run:
    workflows: ["Build", "Test"]
    branches: [main]
jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - name: Send Slack Notification
        uses: 8398a7/action-slack@v3
        with:
          status: ${{ job.status }}
          channel: '#github-actions'
          username: 'GitHub Actions'
          icon_emoji: ':robot_face:'
          webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
Note: The 8398a7/action-slack action is a community-maintained GitHub Action for Slack integration. Ensure the webhook URL is securely stored in GitHub Secrets.
Warning: Slack webhook URLs are sensitive and should never be hardcoded in workflows. Always use ${{ secrets.SLACK_WEBHOOK_URL }} to reference the secret.

Summary of Slack Integration

  • Uses 8398a7/action-slack GitHub Action
  • Supports status-based notifications (success, failure, cancelled)
  • Configurable channel, username, and icon
  • Requires a Slack webhook URL stored as a secret

2. Using Email Notifications

Property Value Description
uses actions/notify GitHub Action for sending email notifications
email.to user@example.com Recipient's email address
email.subject Workflow Status Update Subject line of the email
email.body Workflow {{ workflow }} has completed with status: {{ job.status }} Body content of the email

Example: Configure Email Notification

name: Email Notification
on:
  workflow_run:
    workflows: [Build, Test]
jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - name: Send Email
        uses: actions/notify
        with:
          email.to: user@example.com
          email.subject: Workflow Status Update
          email.body: Workflow {{ workflow }} has completed with status: {{ job.status }}
Note: Requires proper email service configuration (e.g., SMTP settings) to be set up in the repository or organization secrets.

3. Using Discord Webhooks

Property Value Description
webhook.url https://discord.com/api/webhooks/... The Discord webhook URL to send the message to
message.content Hello from GitHub Actions! Text content of the message to send
message.username GitHub Actions Username to display in the webhook message
message.avatar_url https://example.com/avatar.png Avatar URL to display in the webhook message

Example: Sending a Discord Webhook

name: Send Discord Webhook
on:
  push:
    branches:
      - main
jobs:
  send-webhook:
    runs-on: ubuntu-latest
    steps:
      - name: Send to Discord
        uses: actions/github-script@v6
        with:
          script: |
            const webhookUrl = process.env.DISCORD_WEBHOOK_URL;
            const message = {
              content: 'Hello from GitHub Actions!',
              username: 'GitHub Actions',
              avatar_url: 'https://example.com/avatar.png'
            };
            const response = await fetch(webhookUrl, {
              method: 'POST',
              headers: { 'Content-Type': 'application/json' },
              body: JSON.stringify(message)
            });
Note: Ensure the DISCORD_WEBHOOK_URL is set in your repository secrets.

4. Using Microsoft Teams

Property Value Description
webhookUrl https://outlook.office.com/webhook/... Microsoft Teams webhook URL for incoming messages
message Hello from GitHub Actions! Custom message to send to the channel
channel General Name of the channel to post to (optional)

Example: Send a message to Microsoft Teams

name: Send to Microsoft Teams
on:
  push:
    branches:
      - main
jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - name: Send to Teams
        uses: officeapps/teams-webhook@v1.0.0
        with:
          webhookUrl: ${{ secrets.TEAMS_WEBHOOK_URL }}
          message: "Build successful on branch ${{ github.ref }}!"
Note: You must configure the TEAMS_WEBHOOK_URL secret in your repository settings.
Warning: Microsoft Teams webhooks are deprecated in favor of Connectors and Bot Framework.

5. Integrating with Jira

Option Values Notes
jira.base-url https://your-domain.atlassian.net Base URL of your Jira instance
jira.username user@example.com Jira user email or username
jira.token your-api-token Jira API token (generate in Jira Settings)

Example: Create Jira Issue

name: Create Jira Issue
on:
  push:
    branches: [ main ]
jobs:
  create-issue:
    runs-on: ubuntu-latest
    steps:
      - name: Create Issue in Jira
        uses: atlassian/gajira-create@v3
        with:
          server: https://your-domain.atlassian.net
          username: ${{ secrets.JIRA_USER }}
          token: ${{ secrets.JIRA_TOKEN }}
          project: PROJ
          issuetype: Task
          summary: "Automated task from GitHub"
          description: "Created via GitHub Actions"
Note: Ensure the Jira API token has appropriate permissions to create issues in the specified project.
Warning: Store sensitive credentials like JIRA_TOKEN in GitHub Secrets to avoid exposing them.

Jira Integration Capabilities

  • Create issues in Jira from GitHub Actions workflows
  • Update existing Jira issues with status changes
  • Link GitHub commits to Jira issues via commit messages
  • Automate issue transitions based on workflow events

6. Using Kubernetes

Example: Deploying to Kubernetes

name: Deploy to Kubernetes
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up kubectl
        uses: azure/setup-kubectl@v3
      - name: Deploy to cluster
        run: |
          kubectl config view
          kubectl apply -f deployment.yaml
Step Description Action
Checkout Checks out the repository code actions/checkout@v4
Set up kubectl Installs and configures kubectl azure/setup-kubectl@v3
Deploy to cluster Applies Kubernetes manifests kubectl apply -f deployment.yaml
Note: Ensure the Kubernetes cluster is accessible and credentials are properly configured via GitHub Secrets.

Key Concepts

  • kubectl is the command-line tool for interacting with Kubernetes clusters.
  • Use azure/setup-kubectl to install kubectl in the GitHub Actions runner.
  • Deployment manifests (e.g., deployment.yaml) define the desired state of your application.

7. Using Terraform

Option Values Notes
uses hashicorp/setup-terraform@v2 Setup Terraform in the GitHub Actions runner
terraform_version 1.9.5 Version of Terraform to install
working_directory ./infra Directory where Terraform files are located

Example: Setup Terraform

steps:
  - name: Setup Terraform
    uses: hashicorp/setup-terraform@v2
    with:
      terraform_version: 1.9.5
      working_directory: ./infra
Option Values Notes
uses hashicorp/terraform-github-action@v2 Run Terraform commands in GitHub Actions
args plan -out=tfplan Terraform command to execute
working_directory ./infra Directory where Terraform files are located

Example: Run Terraform Plan

steps:
  - name: Terraform Plan
    uses: hashicorp/terraform-github-action@v2
    with:
      args: plan -out=tfplan
      working_directory: ./infra
Note: Ensure that your GitHub repository has the necessary secrets configured for Terraform backend and state management.

8. Using Ansible

Option Values Notes
uses ansible/ansible@v1 GitHub Action for running Ansible playbooks
with.playbook site.yml Path to the playbook file
with.inventory inventory.ini Path to the inventory file
with.verbosity 1 Verbosity level (0-4)

Example: Running an Ansible Playbook

name: Run Ansible Playbook
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Run Ansible Playbook
        uses: ansible/ansible@v1
        with:
          playbook: site.yml
          inventory: inventory.ini
          verbosity: 1
Note: Ensure that the Ansible environment is properly configured with required dependencies and roles.
Warning: The ansible/ansible action runs in a Docker container, so ensure that the playbook and inventory files are correctly mounted.

9. Using Datadog

Option Values Notes
uses datadog/dd-trace-action@v1 GitHub Action for Datadog tracing
with.service my-service Name of the service to trace
with.env production Environment name (e.g., production, staging)
with.version v1.2.3 Version of the service being traced

Example: Setting up Datadog tracing in a workflow

name: Tracing with Datadog
on:
  push:
    branches: [ main ]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
      - name: Install dependencies
        run: npm install
      - name: Trace with Datadog
        uses: datadog/dd-trace-action@v1
        with:
          service: my-app
          env: production
          version: v1.2.3
Note: Ensure DD_API_KEY is set as a secret in your GitHub repository settings for Datadog to receive traces.

10. Using New Relic

Option Values Notes
uses newrelic/new-relic-action@v1 GitHub Action for New Relic integration
with.newrelic-api-key string API key for New Relic account (required)
with.newrelic-license-key string License key for New Relic account (required)
with.newrelic-application-name string Name of the application in New Relic (optional)
with.newrelic-region us or eu Region of New Relic account (optional, defaults to us)

Example: Using New Relic Action

name: Deploy to Production
on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Deploy to New Relic
        uses: newrelic/new-relic-action@v1
        with:
          newrelic-api-key: ${{ secrets.NEW_RELIC_API_KEY }}
          newrelic-license-key: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
          newrelic-application-name: "MyApp"
Note: Ensure that the NEW_RELIC_API_KEY and NEW_RELIC_LICENSE_KEY are stored as GitHub secrets in your repository settings.
Warning: The New Relic GitHub Action requires valid API and license keys to report data. Misconfigured keys will result in failed reporting.

11. Posting to Twitter

Option Values Notes
uses twitter-api/twitter-api-action@v1 GitHub Action for Twitter API integration
with.status string Status message to post to Twitter
with.media string Media file path to upload (optional)

Example: Posting a Status Update

name: Post to Twitter
on:
  push:
    branches: [ main ]
jobs:
  tweet:
    runs-on: ubuntu-latest
    steps:
      - name: Post to Twitter
        uses: twitter-api/twitter-api-action@v1
        with:
          status: "Hello from GitHub Actions!"
Note: Requires Twitter API credentials set as secrets in the repository settings.
Warning: Ensure that your Twitter API credentials are stored securely as GitHub secrets to avoid exposing them.

12. Integrating with PagerDuty

Property Description Values
event Event type to send to PagerDuty alert, acknowledge, resolve
service_key Integration key for PagerDuty service string
incident_key Unique identifier for the incident string
description Summary of the event string

Example: Send Alert to PagerDuty

name: Send Alert to PagerDuty
on:
  workflow_run:
    workflows: ["Build"]
    statuses: [failure]
jobs:
  alert:
    runs-on: ubuntu-latest
    steps:
      - name: Send Alert
        uses: pagerduty/github-actions@v1.0.0
        with:
          event: alert
          service_key: ${{ secrets.PAGERDUTY_SERVICE_KEY }}
          description: "Build failed on ${{ github.workflow }}"
Note: Ensure the PAGERDUTY_SERVICE_KEY secret is configured in your repository settings.
Warning: The pagerduty/github-actions action is not an official GitHub action and should be used with caution.

Was this article helpful?