Terence Eden. He has a beard and is smiling.
Theme Switcher:

Was my website mentioned in a GitHub issue?

· 600 words


This is a quick GitHub action to get alerted every time your website is mentioned in a GitHub issue.

Doing it manually

You can search GitHub for a URl, and sort the results with the newest first, like this:

https://github.com/search?q=%22shkspr.mobi%22&type=issues&s=created&o=desc

Using the API

GitHub has a fairly straightforward API - although it uses slightly different parameters.

https://api.github.com/search/issues?q=shkspr.mobi&sort=created&order=desc

That will return a bunch of items. Here's the 29th. I've truncated it down to only what is necessary for our purposes:

 JSON{
    "html_url": "https://github.com/swicg/activitypub-webfinger/issues/29",
    "id": 3286159033,
    "number": 29,
    "title": "Tracking support for non-ascii characters",
    "user": {
        "login": "evanp",
    },
    "created_at": "2025-08-02T17:52:46Z",
    "updated_at": "2025-08-02T18:50:27Z",
    "body": "One of the benefits of using Webfinger is that it's […]"
}

Action

I'm not very good at creating actions. But this should:

  1. Search GitHub for mentions of your URl.
  2. Store the results.
  3. If there is a new entry - open a new issue describing it.

You will need to set your repository to private in order to not spam other repos. You will also need to go to your repo settings and give the action write permissions. You'll also need a Personal Access Token with sufficient permissions to write to your repo. I bloody hate actions. YAML? Eugh!

 YAMLname: API Issue Watcher

on:
  schedule:
    - cron: '*/59 * * * *'

permissions:
  issues: write
  contents: write

jobs:
  watch-and-create:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Restore latest seen ID
        id: cache-latest
        uses: actions/cache@v4
        with:
          path: .github/latest_seen.txt
          key: latest-seen-1
          restore-keys: |
            latest-seen-

      - name: Fetch latest item from API
        id: fetch
        run: |
          curl -s 'https://api.github.com/search/issues?q=EXAMPLE.COM&s=created&order=desc' > result.json
          jq -r '.items[0].id' result.json > latest_id.txt
          jq -r '.items[0].title' result.json > latest_title.txt
          jq -r '.items[0].html_url' result.json > latest_url.txt
          jq -r '.items[0].body // ""' result.json > latest_body.txt

      - name: Compare with previous run
        id: check
        run: |
          NEW_ID=$(cat latest_id.txt)
          OLD_ID=$(cat .github/latest_seen.txt 2>/dev/null || echo "")
          echo "NEW_ID=$NEW_ID" >> $GITHUB_OUTPUT
          echo "OLD_ID=$OLD_ID" >> $GITHUB_OUTPUT
          if [ "$NEW_ID" != "$OLD_ID" ]; then
            echo "NEW_ITEM=true" >> $GITHUB_OUTPUT
          else
            echo "NEW_ITEM=false" >> $GITHUB_OUTPUT
          fi

      - name: Open new issue if new item found
        if: steps.check.outputs.NEW_ITEM == 'true'
        uses: actions/github-script@v7
        with:
          github-token: ${{ secrets.MY_PAT }}
          script: |
            const fs = require('fs');
            const title = fs.readFileSync('latest_title.txt', 'utf8').trim();
            const url = fs.readFileSync('latest_url.txt', 'utf8').trim();
            const body = fs.readFileSync('latest_body.txt', 'utf8').trim();
            await github.rest.issues.create({
              owner: context.repo.owner,
              repo: context.repo.repo,
              title: `[API] ${title}`,
              body: `Found new item: [${title}](${url})\n\n${body}`
            });

      - name: Update latest seen ID
        if: steps.check.outputs.NEW_ITEM == 'true'
        run: |
          mkdir -p .github
          cp latest_id.txt .github/latest_seen.txt

      - name: Save cache
        uses: actions/cache@v4
        with:
          path: .github/latest_seen.txt
          key: latest-seen-1
          restore-keys: |
            latest-seen-

This is probably all kinds of wrong. If you know how to improve it, please let me know!


Share this post on…

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

See allowed HTML elements: <a href="" title="">
<abbr title="">
<acronym title="">
<b>
<blockquote cite="">
<br>
<cite>
<code>
<del datetime="">
<em>
<i>
<img src="" alt="" title="" srcset="">
<p>
<pre>
<q cite="">
<s>
<strike>
<strong>

To respond on your own website, write a post which contains a link to this post - then enter the URl of your page here. Learn more about WebMentions.