diff --git a/.github/vouch_issue_message.md b/.github/vouch_issue_message.md new file mode 100644 index 00000000000..db0025a93b1 --- /dev/null +++ b/.github/vouch_issue_message.md @@ -0,0 +1,5 @@ +Users are no longer allowed to open issues themselves, please open a discussion instead. + +Please see the [wiki](https://wiki.hyprland.org/Contributing-and-Debugging/Issue-Guidelines/) on why this is the case.\n\nWe are volunteers, and we need your cooperation to make the best software we can. Thank you for understanding! ❤️ + +[Open a discussion here](https://github.com/hyprwm/Hyprland/discussions) \ No newline at end of file diff --git a/.github/workflows/close-issues.yml b/.github/workflows/close-issues.yml deleted file mode 100644 index 55f4e126ab9..00000000000 --- a/.github/workflows/close-issues.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Close Unauthorized Issues - -on: - workflow_dispatch: - issues: - types: [opened] - -jobs: - close-unauthorized-issues: - runs-on: ubuntu-latest - permissions: - issues: write - steps: - # XXX: This *could* be done in Bash by abusing GitHub's own tool to interact with its API - # but that's too much of a hack, and we'll be adding a layer of abstraction. github-script - # is a workflow that eases interaction with GitHub API in the workflow run context. - - name: "Close 'unauthorized' issues" - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const ALLOWED_USERS = ['vaxerski', 'fufexan', 'NotAShelf']; - const CLOSING_COMMENT = 'Users are no longer allowed to open issues themselves, please open a discussion instead.\n\nPlease see the [wiki](https://wiki.hyprland.org/Contributing-and-Debugging/Issue-Guidelines/) on why this is the case.\n\nWe are volunteers, and we need your cooperation to make the best software we can. Thank you for understanding! ❤️\n\n[Open a discussion here](https://github.com/hyprwm/Hyprland/discussions)'; - - async function closeUnauthorizedIssue(issueNumber, userName) { - if (ALLOWED_USERS.includes(userName)) { - console.log(`Issue #${issueNumber} - Created by authorized user ${userName}`); - return; - } - - console.log(`Issue #${issueNumber} - Unauthorized, closing`); - - await github.rest.issues.update({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueNumber, - state: 'closed', - state_reason: 'not_planned' - }); - - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueNumber, - body: CLOSING_COMMENT - }); - } - - if (context.eventName === 'issues' && context.payload.action === 'opened') { - // Direct access to the issue that triggered the workflow - const issue = context.payload.issue; - - // Skip if this is a PR - if (issue.pull_request) { - console.log(`Issue #${issue.number} - Skipping, this is a pull request`); - return; - } - - // Process the single issue that triggered the workflow - await closeUnauthorizedIssue(issue.number, issue.user.login); - } else { - // For manual runs, we need to handle pagination - async function* fetchAllOpenIssues() { - let page = 1; - let hasNextPage = true; - - while (hasNextPage) { - const response = await github.rest.issues.listForRepo({ - owner: context.repo.owner, - repo: context.repo.repo, - state: 'open', - per_page: 100, - page: page - }); - - if (response.data.length === 0) { - hasNextPage = false; - } else { - for (const issue of response.data) { - yield issue; - } - page++; - } - } - } - - // Process issues one by one - for await (const issue of fetchAllOpenIssues()) { - try { - // Skip pull requests - if (issue.pull_request) { - console.log(`Issue #${issue.number} - Skipping, this is a pull request`); - continue; - } - - await closeUnauthorizedIssue(issue.number, issue.user.login); - } catch (error) { - console.error(`Error processing issue #${issue.number}: ${error.message}`); - } - } - } diff --git a/.github/workflows/vouch-issues.yml b/.github/workflows/vouch-issues.yml new file mode 100644 index 00000000000..0227dc17bb1 --- /dev/null +++ b/.github/workflows/vouch-issues.yml @@ -0,0 +1,42 @@ +name: Vouch Issue Check + +on: + issues: + types: [opened, reopened] + + +permissions: + contents: read + issues: write + +jobs: + check-vouch: + runs-on: ubuntu-latest + + steps: + - name: Check out template + uses: actions/checkout@v6 + with: + persist-credentials: false + + - name: Verify central Issues Vouch list + env: + GH_TOKEN: ${{ github.token }} + run: | + gh api \ + "/repos/${{ github.repository_owner }}/.github/contents/vouch/VOUCHED_ISSUE.td?ref=${{ github.event.repository.default_branch }}" \ + >/dev/null + + - name: Enforce central Vouch list + uses: mitchellh/vouch/action/check-issue@v1 + with: + issue-number: ${{ github.event.issue.number }} + repo: ${{ github.repository }} + vouched-repo: ${{ github.repository_owner }}/.github + vouched-file: vouch/VOUCHED_ISSUE.td + template-file: .github/vouch_issue_message.md + require-vouch: true + auto-close: true + dry-run: false + env: + GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file