forked from krille-chan/fluffychat
-
Notifications
You must be signed in to change notification settings - Fork 3
29 lines (27 loc) · 1.08 KB
/
check_duplicates.yaml
File metadata and controls
29 lines (27 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
name: Check duplicates
on:
issues:
types: [opened]
jobs:
check_duplicates:
runs-on: ubuntu-latest
env:
title: ${{ github.event.issue.title }}
author: ${{ github.event.issue.user.login }}
number: ${{ github.event.issue.number }}
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v6
- name: Check duplicates
run: |
title=$(printf %q "${{ env.title }}")
issues=$(gh issue list --search '${{ title }}' --json number,title,url)
number=${{ env.number }}
issues_filtered=$(echo "$issues" | jq --arg num "$number" 'map(select(.number != ($num | tonumber)))')
if [ "$(echo "$issues_filtered" | jq length)" -eq 0 ]; then
echo "No duplicates found."
else
issues_markdown=$(echo "$issues_filtered" | jq -r '.[] | "- [" + .title + "](" + .url + ")"')
formatted_body=$(echo -e "@${{ env.author }}\nPossible duplication of:\n$issues_markdown")
gh issue comment ${{ github.event.issue.number }} --body "$formatted_body"
fi