Due to an influx of spam, we have had to temporarily disable account registrations. Please write an email to accountsupport@archlinux.org, with your desired username, if you want to get access. Sorry for the inconvenience.
Since GitHub seems to be unable to provide a way to disable Pull Requests for repositories we might want to deploy a script to automatically close PRs with a message pointing to the GitLab repository.
The Linux repo uses this python script, it does what we want and is quite battle proven. However, it polls the GitHub API instead of providing a web hook endpoint, which might introduce unnecessary overhead.
This project uses web hooks, but it only acts on merged PRs.
Also, where should we deploy the script and optionally the web hook endpoint? Directly on the GitLab server?
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related or that one is blocking others.
Learn more.
None of those options ;-) Web hooks are the wrong tool too I think.
This should be done with a Github Actions workflow with a on: [pull_request] trigger. This way it wouldn't require any infustructure and would only operate directly on the Github repo.
As long as there is an Arch official mirror on Github I think having a .github folder with anything specific to it being there is probably okay. Another thing that could probably go in there is a PR template that warned people off before they even get their PR open. I'm sure opinions vary, but Actions are by far the lowest technical overhead way to set this up.
I'm not sure that action you linked to is the best option. Maybe this one?
name:Close all Pull Requests and comment on themon:[pull_request]jobs:close-prs:runs-on:ubuntu-lateststeps:-name:Close Pulluses:peter-evans/close-pull@v1with:comment:Auto-closing pull requestdelete-branch:true
Multiline-Comments work like this:
comment:># Markdown!Multiline!No!Sure!Oooh!
I haven't figured out how to use template files yet.
I think i would be more ideal to create our own action, so we don't need to sync the template between repos. Then we can just add this workflow to all the mirrored repos:
name:Close all Pull Requests and comment on themon:[pull_request]jobs:close-prs:runs-on:ubuntu-lateststeps:-name:Close Pulluses:archlinux/close-pull-repo
Each webhook can be installed on an organization or a specific repository. Once installed, they will be triggered each time one or more subscribed events occurs on that organization or repository like deployments, commits, and repository changes, etc
Using the information above, seems like the proposal from Jelle of using an organizational webhook to be the way to go.
I personally feel that Kristian's proposal seems to be the most versatile and "clean" since it is built in and will possibly require less effort than a webhooks based solution. If we create our own action we will have full control of what we can do and will avoid the need for web-hooks (which will also require a WSGI application) or polling. All we will need is a user token (owner or collaborator on all mirrored repos). After a short search it seems possible that we can automate the GitHub action sync across all the repos of the organization, something similar to this https://medium.com/@adrianjost/how-to-sync-github-actions-across-repositories-f0b09dc9a9d8
I mean adding the workflow to all the mirrored repos is also acceptable but it will be a manual process and depending on how often we create new repos could be problematic and it conflicts with the requirements mentioned above.
Now, which method is more maintainable I guess is open to discussion. Happy to discuss further but in the meantime I will start looking into both creating a custom GitHub action for our purposes as well as webhooks.
If we do go with webhooks in the end, is Python the preferred way or?
@svenstaro I will be using my account for the tests I guess that should be enough for now but not sure if I will also need access to the organization repos down the line.
All we will need is a user token (owner or collaborator on all mirrored repos)
We can just use the GITHUB_TOKEN, we don't need to create a PAT token.
I mean adding the workflow to all the mirrored repos is also acceptable but it will be a manual process and depending on how often we create new repos could be problematic and it conflicts with the requirements mentioned above.
Another option is running the workflow on a schedule, that would require a PAT token though. Then we don't need to add a workflow to every mirrored repository.
I have a working solution using a simple Python Flask webserver application acting as a listener to GitHub webhooks. It works pretty well and seems like a good option for what we are tying to do. This process does require a PAT and for our purposes an organizational PAT with full access to all the repos. It is also using a secret to verify the post request is coming from GitHub.
Looks cool, some things I would like to bring up (note they are not that important right now):
Create a separate project this app when it's finalised, then we can easily package it and include it in our repos. We should be able to configure which repos to auto-close, as currently some are still on Github. Maybe a configuration option like repos: 'all' to close it for all repository's.
What to do once a PR is opened/reopend currently I add a comment and close it.
I wonder if we want to make the comments configurable, probably should be an option in the configuration file.
Here is a quick list of our available options (based on my own research and the community's feedback) for the PR auto closure task. I wanted to list pros and cons for each option but I think that is subjective so I will avoid that.
Use GitHub webhooks with a WSGI application. We can monitor the pull_request event for the opened or reopened actions and then close them accordingly and possibly also add an admin comment that can be customizable. Unfortunately the GitHub REST API for editing pull requests does not allow us to lock it only close it. Now since each webhook can be installed on an organization this will work for all our mirrors. It does require a PAT with minimum public_repo access. Things to consider beyond security is the fact that we need a running webserver and a way to avoid rate limit abuse as someone can simply click re-open all the time on the PR.
Use a GitHub action. Note actions operate per repository which means that we will need to copy the action to all mirrors. If we find a way to sync our action to all organization repos not a big deal I guess unless we hate duplication. A bit more work but does not require a webserver or using a PAT since we can take advantage of GITHUB_TOKEN.
A scheduled workflow. According to Kristian
running the workflow on a schedule would require a PAT but we don't need to add a workflow to every mirrored repository.
I feel this might be through templates? According to the documentation:
A workflow template can be used by any repository within the organization
But not sure how/if that can be done automatically. There was also a suggestion that if we go with a timed schedule then maybe we can use GitLab CI instead of GitHub workflows.
Use a GitHub app like pull_closer that seems to allow for finer and safer permissions to the repos. It will require hosting.
I do not mind looking further into any of the options mentioned above (or look for even more options...) but we need to decide how to proceed sooner than later so that we are all in line.
I think a scheduled github action would be the easiest approach here, it does not require any hosting from our part. Unfortunately, github has a limit of 2000 min/month (33 h/month) on github actions (see the documentation). So, we would probably need to run it at something like each 10~30min.
To be clear, this would be running in a single repo, the script that we run would close the open PRs for all organization repos.
If we opt to host our own thing, it would require more overhead from our part. Let me know what we want to do, I would go for the scheduled github action and adapt if it gives us trouble.
I think a scheduled github action would be the easiest approach here, it does not require any hosting from our part.
If we decide to go that route, we should at least consider using Gitlab CI.
Unfortunately, github has a limit of 2000 min/month (33 h/month) on github actions (see the documentation). So, we would probably need to run it at something like each 10~30min.
The doc says:
GitHub Actions usage is free for public repositories. For private repositories, each GitHub account receives a certain amount of free minutes and storage, depending on the product used with the account.
Hello Filipe, Kristian thank you both for your input.
I guess as I mention above, it makes sense to first decide how to proceed given the available options and then we can look into the desired choice in more detail. We can always start up a discussion if an unexpected issue pops up.
It would also be good to know if anyone else is "actively" working on this issue so that we do not do duplicate work.
I will be happy to look into the proposed solution once @jelle decides how to proceed. If anyone else wants to take over then I will move on to a different task.
The Repository Interactions API allows people with owner or admin access to temporarily restrict which users can comment, open issues, or create pull requests in a public repository. When restrictions are enabled, only the specified group of GitHub users will be able to participate in interactions. Restrictions expire 24 hours from the time they are set. Here's more about the groups of GitHub users:
Existing users: When you limit interactions to existing_users, new users with accounts less than 24 hours old who have not previously contributed and are not collaborators will be temporarily restricted in the respository.
Contributors only: When you limit interactions to contributors_only, users who have not previously contributed and are not collaborators will be temporarily restricted in the respository.
Collaborators only: When you limit interactions to collaborators_only, users who are not collaborators will be temporarily restricted in the respository.
It would require calling the API once a day though.
The project has been moved to https://gitlab.archlinux.org/archlinux/github-pull-closer/, a PAT token created with scope public_repo, the webhook has been added to all read-only mirrored github projects and a MR created with updated instructions for setting up mirroring: !423 (merged).