[BUG] AudioMuse-AI Opens Multiple Browser Windows #93
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # When an issue is closed as completed or a discussion is marked as answered | |
| # (GitHub Actions has no "discussion closed" trigger), post a short automated | |
| # message: a thank-you if the author already starred the repo, otherwise an | |
| # invitation to star it. Bots and the project's own team (owner, members, | |
| # collaborators) are skipped. Since June 2026 GitHub restricts a repo's | |
| # stargazer list to admins/collaborators, so the star check reads the | |
| # author's own starred-repos list instead; if that check fails it falls | |
| # back to the invitation message. | |
| name: Thank issue and discussion authors when resolved | |
| on: | |
| issues: | |
| types: | |
| - closed | |
| discussion: | |
| types: | |
| - answered | |
| permissions: {} | |
| jobs: | |
| thank-on-issue: | |
| if: github.event_name == 'issues' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| steps: | |
| - name: Post a short thank-you comment | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const issue = context.payload.issue; | |
| if (issue.state_reason !== 'completed') { | |
| console.log(`Issue #${issue.number} closed as "${issue.state_reason}", not completed. Skipping.`); | |
| return; | |
| } | |
| const author = issue.user.login; | |
| if (issue.user.type === 'Bot' || author.endsWith('[bot]')) { | |
| console.log(`Skipping bot account ${author}.`); | |
| return; | |
| } | |
| if (['OWNER', 'MEMBER', 'COLLABORATOR'].includes(issue.author_association)) { | |
| console.log(`Skipping team member ${author} (${issue.author_association}).`); | |
| return; | |
| } | |
| const fullName = `${owner}/${repo}`.toLowerCase(); | |
| let hasStarred = false; | |
| try { | |
| let pages = 0; | |
| for await (const { data } of github.paginate.iterator( | |
| github.rest.activity.listReposStarredByUser, | |
| { username: author, per_page: 100 }, | |
| )) { | |
| if (data.some((r) => ((r.full_name || (r.repo && r.repo.full_name) || '')).toLowerCase() === fullName)) { | |
| hasStarred = true; | |
| break; | |
| } | |
| if (++pages >= 30) { | |
| console.log(`Stopped star check for ${author} after ${pages} pages.`); | |
| break; | |
| } | |
| } | |
| } catch (error) { | |
| console.log(`Could not check stars for ${author}: ${error.message}`); | |
| } | |
| const thanksForStar = `We've closed the issue now, thanks for having starred AudioMuse-AI and supporting self-hosted music here on GitHub! It really helps the project grow!`; | |
| const pleaseStar = `We've closed the issue now, so if you like AudioMuse-AI and want to improve self-hosted music, why not consider giving us a star here on GitHub? It helps the project grow!`; | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: issue.number, | |
| body: hasStarred ? thanksForStar : pleaseStar, | |
| }); | |
| thank-on-discussion: | |
| if: github.event_name == 'discussion' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| discussions: write | |
| steps: | |
| - name: Post a short thank-you comment | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const discussion = context.payload.discussion; | |
| const author = discussion.user.login; | |
| if (discussion.user.type === 'Bot' || author.endsWith('[bot]')) { | |
| console.log(`Skipping bot account ${author}.`); | |
| return; | |
| } | |
| if (['OWNER', 'MEMBER', 'COLLABORATOR'].includes(discussion.author_association)) { | |
| console.log(`Skipping team member ${author} (${discussion.author_association}).`); | |
| return; | |
| } | |
| const fullName = `${owner}/${repo}`.toLowerCase(); | |
| let hasStarred = false; | |
| try { | |
| let pages = 0; | |
| for await (const { data } of github.paginate.iterator( | |
| github.rest.activity.listReposStarredByUser, | |
| { username: author, per_page: 100 }, | |
| )) { | |
| if (data.some((r) => ((r.full_name || (r.repo && r.repo.full_name) || '')).toLowerCase() === fullName)) { | |
| hasStarred = true; | |
| break; | |
| } | |
| if (++pages >= 30) { | |
| console.log(`Stopped star check for ${author} after ${pages} pages.`); | |
| break; | |
| } | |
| } | |
| } catch (error) { | |
| console.log(`Could not check stars for ${author}: ${error.message}`); | |
| } | |
| const thanksForStar = `Your discussion has its answer now - thanks for having starred AudioMuse-AI and supporting self-hosted music here on GitHub! It really helps the project grow!`; | |
| const pleaseStar = `Your discussion has its answer now, so if you like AudioMuse-AI and want to improve self-hosted music, why not consider giving us a star here on GitHub? It helps the project grow!`; | |
| await github.graphql( | |
| `mutation($discussionId: ID!, $body: String!) { | |
| addDiscussionComment(input: { discussionId: $discussionId, body: $body }) { | |
| comment { id } | |
| } | |
| }`, | |
| { discussionId: discussion.node_id, body: hasStarred ? thanksForStar : pleaseStar }, | |
| ); |