Skip to content

Automated Email Reply on Stock Center Order Labels #1197

@ktun95

Description

@ktun95
- [x] fix `go-github` version mismatch across packages.
- [x] Define Label Email command.
- [x] Define struct for OrderData.
        - recipient email address
        - order id
- [ ] Fetch issue `github.event.issue.number`.
    - [x] Write function
    - [x] Create mock GET issue data
    - [x] Add route to routeTable
    - [ ] Reevaluate
        - Does this need testing?
    - [ ] Write test(s) for function
        - [ ] Implement route in mock github API server
- [x] Convert Github Issue body markdown to HTML
    - [x] Use `yuin/goldmark` package
- [x] Extract recipient order data from HTML
    - [x] Extract Order ID from second paragraph
    - [x] Extract Billing Address from table with "Billing Information"
    - [x] Write test(s)
- [x] Extract recipient order data from markdown (Regexp)
    - [x] Write function(s)
    - [x] Write test(s)
- [ ] Email CC?
- [ ] Prepare email body from template.
    - [x] Write functions
    - [ ] Write test(s)
    - [ ] Refactor template file path logic.
        - should not be hardcoded
    
- [x] Make API request to Mailgun endpoint.

Description

When a specific label is added to an issue, send an email to the address in listed in the email body.

Requirements

  • An email is sent automatically when a label is added to an issue.
  • Receiver email address and other information should be retrieved from the issue body.
  • Email subject and body differ based on label added.
    • Growing / in Preparation
    • Shipping
    • invalid

Outline

  1. Subscribe to github issue label event on Stock-Center-Orders
  2. Extract receiver information from the issue body.
    • Email Address
    • Order ID
  3. Generate Email subject on body from template using receiver information.
  4. Send an email from some address; dictybase@northwestern.edu
sequenceDiagram
    actor Richard
    participant Stock-Center-Orders-repo
    participant gha-runner
    participant dictybase-docker/github-actions
    participant mailgun
    actor Order Recipient

Richard->>Stock-Center-Orders-repo: Adds label to issue
Stock-Center-Orders-repo->>gha-runner: Label event triggers workflow to run on
gha-runner->>dictybase-docker/github-actions: Checks out code
dictybase-docker/github-actions->>mailgun: Sends API request to
mailgun ->> Order Recipient: sends email to
Loading

Testing

There is a Stock-Center-Orders test repository that can be used for testing?

Approaches

Github Webhooks

Pros:

  • Direct, real-time notifications when label events occur
  • Full control over the endpoint logic and email sending
  • Can process the payload immediately and send emails synchronously
  • No dependency on GitHub's infrastructure for execution (runs on your server)
  • Can integrate with existing services like your event-messenger
  • Payload contains all necessary information (issue body, labels, etc.)

Cons:

  • Requires hosting and maintaining a web server/endpoint
  • Need to handle webhook authentication and security
  • Must manage uptime, scaling, and error handling yourself
  • Infrastructure costs for running the service
  • More complex deployment and monitoring setup
  • Need to handle retries and failures manually

Github Actions

Pros:

  • No server infrastructure to maintain (serverless)
  • Runs directly in GitHub's infrastructure
  • Easy to set up with YAML configuration
  • Built-in secret management for email credentials
  • Version controlled alongside your code
  • Free tier available for public repositories
  • Simple to test and debug with workflow runs
  • Can use existing actions from the marketplace

Cons:

  • Subject to GitHub Actions usage limits and quotas
  • Less flexible than custom server code
  • Debugging can be slower (need to trigger events or use workflow_dispatch)
  • May have cold start delays
  • Harder to integrate with existing services like event-messenger
  • Limited to GitHub's execution environment

Unknowns

  • How will the project be organized? Where should it be kept?

  • Is using Github Webhooks viable?

    • Can subscribe to issue label events
    • It sends a payload to an endpoint of our choosing. Can it specify all the necessary information in that payload?
  • What is our event-messenger service used for? Can it be used for the project?

  • How does email even work?

    • SMTP?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions