Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling issues in archived repos. #235

Open
sshivaditya2019 opened this issue Dec 12, 2024 · 3 comments
Open

Handling issues in archived repos. #235

sshivaditya2019 opened this issue Dec 12, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@sshivaditya2019
Copy link
Owner

sshivaditya2019 commented Dec 12, 2024

Issues reported in repositories that have been archived (i.e., set to read-only) should not remain open, as no further action can be taken on them. Even though the labels on these issues might still be relevant, no updates, assignments, or changes can be made to the issue itself and other issues in other repos.1

Footnotes

  1. ⚠ 89% possible duplicate - Automatically Close Issues in Archived Repositories

@sshivaditya2019 sshivaditya2019 added documentation Improvements or additions to documentation enhancement New feature or request duplicate This issue or pull request already exists good first issue Good for newcomers bug Something isn't working and removed documentation Improvements or additions to documentation enhancement New feature or request duplicate This issue or pull request already exists good first issue Good for newcomers bug Something isn't working labels Dec 12, 2024
@sshivaditya2019 sshivaditya2019 added enhancement New feature or request duplicate This issue or pull request already exists and removed enhancement New feature or request duplicate This issue or pull request already exists labels Dec 12, 2024
@test-app-ubo
Copy link

test-app-ubo bot commented Dec 12, 2024

Note

The following contributors may be suitable for this task:

0x4007

85% Match ubiquity/devpool-directory-tasks#32
76% Match ubiquibot/production#8

sshivaditya2019

85% Match sshivaditya2019/test-public#168

Keyrxng

76% Match ubiquity/devpool-directory-tasks#23

@sshivaditya2019 sshivaditya2019 added enhancement New feature or request and removed duplicate This issue or pull request already exists labels Dec 12, 2024
@sshivaditya2019
Copy link
Owner Author

/ask how do you think we should handle the archived repos ?

@test-app-ubo
Copy link

test-app-ubo bot commented Dec 13, 2024

To effectively manage archived repositories, it's recommended to implement an automated process that handles issues within these repositories appropriately. Here's a comprehensive approach:

  1. Check Repository Status:
    Utilize Octokit to determine if a repository is archived. This can be achieved by fetching the repository details and inspecting the archived property.

    import { Octokit } from "@octokit/rest";
    
    const octokit = new Octokit({ auth: `YOUR_GITHUB_TOKEN` });
    
    async function isRepoArchived(owner: string, repo: string): Promise<boolean> {
      const { data } = await octokit.repos.get({
        owner,
        repo,
      });
      return data.archived;
    }
  2. Close the Issue:
    If the repository is confirmed to be archived, automatically close the issue while preserving existing labels and comments.

    async function closeIssue(owner: string, repo: string, issueNumber: number): Promise<void> {
      await octokit.issues.update({
        owner,
        repo,
        issue_number: issueNumber,
        state: "closed",
      });
    }
  3. Notify the User (Optional):
    Optionally, add a comment to inform the user that the issue has been closed due to the repository being archived.

    async function notifyUser(owner: string, repo: string, issueNumber: number): Promise<void> {
      await octokit.issues.createComment({
        owner,
        repo,
        issue_number: issueNumber,
        body: "This repository is archived and is no longer accepting new issues. The issue has been closed automatically.",
      });
    }
  4. Integrate with GitHub Actions:
    Set up a GitHub Action that triggers on new issue creation. This action will execute the above functions to ensure issues in archived repositories are handled appropriately.

    name: Handle Archived Repository Issues
    
    on:
      issues:
        types: [opened]
    
    jobs:
      close-archived-issue:
        runs-on: ubuntu-latest
        steps:
          - name: Check if repository is archived
            id: check_archive
            uses: actions/github-script@v6
            with:
              script: |
                const { owner, repo } = context.repo;
                const response = await github.repos.get({
                  owner: owner,
                  repo: repo
                });
                return response.data.archived;
    
          - name: Close issue if archived
            if: steps.check_archive.outputs.result == 'true'
            uses: actions/github-script@v6
            with:
              script: |
                const { issue } = context;
                await github.issues.update({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  issue_number: issue.number,
                  state: 'closed'
                });
                await github.issues.createComment({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  issue_number: issue.number,
                  body: 'This repository is archived and is no longer accepting new issues. The issue has been closed automatically.'
                });
  5. Maintain Repository Hygiene:
    By implementing the above steps, you ensure that:

    • No issues remain open in archived repositories, preventing confusion.
    • Users are informed about the status of the repository and the reason for issue closure.
    • Repository management remains efficient without manual intervention.

Notes:

  • Ensure that the GitHub token used has the necessary permissions to read repository data and manage issues.
  • Customize the notification message as needed to fit your project's tone and guidelines.
  • Testing the workflow in a non-critical repository first is advisable to ensure it functions as expected.

Implementing this automated handling of issues in archived repositories will maintain the integrity and cleanliness of your project's issue tracking system, providing a seamless experience for both maintainers and contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant