Suggest Related Links Action
Tags: actionshackathon, githubactions, github
Published: 2020-09-17 22:44:50

## My Workflow 

Our GitHub Action is [peaceiris/actions-suggest-related-links] which suggests related or similar issues, documents, and links. 

{% github peaceiris/actions-suggest-related-links %}

> A GitHub Action to suggest related or similar issues, documents, and links. Based on the power of NLP and fastText.

Sometimes, users create a new issue that is similar to already opened or closed issues. When you face the issue, you need to find similar issues or related links and post it as a comment. That process is a pain, right? This action can do it instead of you!

![Suggest Related Links Action example result | peaceiris/actions-suggest-related-links](https://dev-to-uploads.s3.amazonaws.com/i/obhoy6gpwj8dnrojdbej.png)

e.g. `.github/workflows/suggest-related-links.yml`

```yaml
name: 'Suggest Related Links'

on:
  issues:
    types:
      - opened
      - edited
  workflow_dispatch:
  schedule:
    - cron: '13 13 * * */7'

jobs:
  action:
    runs-on: ubuntu-18.04
    steps:
      - name: Cache dependencies
        uses: actions/cache@v2
        with:
          path: ~/actions-suggest-related-links-tmp
          key: ${{ runner.os }}-action-${{ hashFiles('~/actions-suggest-related-links-tmp/training-data.json') }}
          restore-keys: |
            ${{ runner.os }}-action-

      - uses: peaceiris/actions-suggest-related-links@v1.1.1
      - uses: peaceiris/actions-suggest-related-links/models/fasttext@v1.1.1
        if: github.event_name == 'issues'
        with:
          version: v1.1.1
      - uses: peaceiris/actions-suggest-related-links@v1.1.1
        with:
          mode: 'suggest'
          repository: 'peaceiris/actions-gh-pages'
          unclickable: true
```



## Workflow Overview

This action mainly consists of 5 parts: Data Collection, Preprocessing, Train model, Find similar issues, and Suggest links.

[peaceiris/actions-suggest-related-links]: https://github.com/peaceiris/actions-suggest-related-links

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/r5sz76dqtuzzv6r3j0yk.jpg)

### Data Collection

All issues of the repository are collected with the GitHub API. The issues include the title, body, and comments. Training Data is regularly collected using the scheduling function and output as an artifact and saved as a cache.

### Preprocessing

The Markdown format is converted to plain text with [unified].
At this time, symbols that are not alphabetic characters are deleted.

- https://github.com/peaceiris/actions-suggest-related-links/blob/main/actions/src/preprocess.ts

[unified]: https://unifiedjs.com/

### Train Model

When a new issue is created or updated, the fastText model is trained.
In accordance with its name, fastText has the advantage of very short inference times.

We think training time at the GitHub Actions runners won't be an issue.
In the case of [GitHub Actions for GitHub Pages] repository, the training execution time is 1 sec and the total execution time is about 30 sec.

[fastText]: https://fasttext.cc/
[GitHub Actions for GitHub Pages]: https://github.com/peaceiris/actions-gh-pages

### Find Similar Issues

Calculate word vectors of training data and word vectors of posted data in fastText. The cosine similarity is used to determine which word vectors of training data is close to the word vectors of the posted data. The higher the cosine similarity, the more similar the sentence.

### Suggest Issues

Some related links which are similar to the created issue body will be listed by this action.

![Suggest Related Links Action example result | peaceiris/actions-suggest-related-links](https://dev-to-uploads.s3.amazonaws.com/i/obhoy6gpwj8dnrojdbej.png)

https://github.com/peaceiris/actions-suggest-related-links/issues/2



## Submission Category

- Maintainer Must-Haves

[Note]: # (Maintainer Must-Haves, DIY Deployments, Interesting IoT, Phone Friendly, or Wacky Wildcards)



## Additional Resources / Info

Maintainers

- [peaceiris - DEV Community 👩‍💻👨‍💻](https://dev.to/peaceiris)
- [Kaisei Shimura - DEV Community 👩‍💻👨‍💻](https://dev.to/skaisei)

Dependencies

- [actions/toolkit: The GitHub ToolKit for developing GitHub Actions.](https://github.com/actions/toolkit)
- [facebookresearch/fastText: Library for fast text representation and classification.](https://github.com/facebookresearch/fastText)
- [unified](https://unifiedjs.com/)