Skip to content

spenserblack/actions-magic-ticket

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Magic Ticket

CI Check dist/ codecov

Congratulate a user when they get the magic issue/PR/discussion number.

Example

# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
# for more details. Some good triggers are opened issues, opened pull requests, and
# created discussions
on:
  issues:
    types: [opened]

job:
  congratulations:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write
    steps:
      - uses: spenserblack/actions-magic-ticket@main
        with:
          regex: "\\d00$"
          message: |
            Congratulations @{{ actor }} on submitting issue #{{ number }}! :tada:

The above workflow would generate a comment that looks something like this:

Congratulations @octocat on submitting issue #100! :tada:

Inputs

regex

As stated in the example, this is matched against reference number of the issue, pull request, or discussion that triggered the workflow. Obviously, this value will always be numeric, so be careful to avoid regular expressions that will never match! Also, make sure that backslashes are properly escape in quoted strings!

Examples

  • \d00$: Comment every 100th ticket.
  • ^(\d)\1\1+$: Comment every time the ticket number is 3 or more digits repeated. E.g. 777 or 1111.

message

A nunjucks template. See nunjucks for more information.

Variables

  • actor: The user that triggered this workflow (e.g. the issue creator)
  • number: The reference number for the issue, discussion, or pull request