Giter Site home page Giter Site logo

larssieboy18 / automatic-contrib-prs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from github/automatic-contrib-prs

0.0 0.0 0.0 59 KB

Automatically open a pull request for repositories that have no CONTRIBUTING.md file

License: MIT License

Python 86.15% Dockerfile 13.85%

automatic-contrib-prs's Introduction

automatic-contrib-prs

.github/workflows/linter.yml CodeQL Docker Image CI

Automatically open a pull request for repositories that have no CONTRIBUTING.md file for a targeted set of repositories.

What this repository does

This code is for a GitHub Action that opens pull requests in the repositories that have a specified repository topic and also don't have a CONTRIBUTING.md file.

Why would someone do this

It is desirable, for example, for all Open Source and InnerSource projects to have a CONTRIBUTING.md file that specifies for new contributors what the processes and procedures are for making a new contribution. This has been done in some large GitHub customers organizations.

How it does this

  • It pulls a list of labelled repositories from a repos.json which can be generated by the InnerSource-Crawler GitHub Action.
  • It opens a pull request in each of those repositories which adds the CONTRIBUTING.md file with some template contents.

Use as a GitHub Action

  1. Create a repository to host this GitHub Action or select an existing repository.
  2. Create the env values from the sample workflow below (GH_TOKEN, GH_ACTOR, PR_TITLE, PR_BODY, and ORGANIZATION) with your information as repository secrets. More info on creating secrets can be found here. Note: Your GitHub token will need to have read/write access to all the repositories in the repos.json file.
  3. Copy the below example workflow to your repository and put it in the .github/workflows/ directory with the file extension .yml (ie. .github/workflows/auto-contrib-file.yml)

Example workflow

name: Find proper repos and open CONTRIBUTING.md prs

on:
  workflow_dispatch:

jobs:
  build:
    name: Open CONTRIBUTING.md in OSS if it doesnt exist
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2
    
    - name: Find OSS repository in organization
      uses: docker://ghcr.io/zkoppert/innersource-crawler:v1
      env:
        GH_TOKEN: ${{ secrets.GH_TOKEN }}
        ORGANIZATION: ${{ secrets.ORGANIZATION }}
        TOPIC: open-source

    - name: Open pull requests in OSS repository that are missing contrib files
      uses: docker://ghcr.io/github/automatic-contrib-prs:v1
      env:
        GH_TOKEN: ${{ secrets.GH_TOKEN }}
        ORGANIZATION: ${{ secrets.ORGANIZATION }}
        GH_ACTOR: ${{ secrets.GH_ACTOR }}
        PR_TITLE: ${{ secrets.PR_TITLE }}
        PR_BODY: ${{ secrets.PR_BODY }}

Scaling for large organizations

  • GitHub Actions workflows have time limits currently set at 72 hours per run. If you are operating on more than 1400 repos or so with this action, it will take several runs to complete.

Contributions

We would ❤️ contributions to improve this action. Please see CONTRIBUTING.md for how to get involved.

Instructions to run locally without Docker

  • Clone the repository or open a codespace
  • Create a personal access token with read only permissions
  • Copy the .env-example file to .env
  • Edit the .env file by adding your Personal Access Token to it and the desired organization, pull request title and body, and actor (GitHub username)
  • Install dependencies python3 -m pip install -r requirements.txt
  • Run the code python3 open_contrib_pr.py
  • After running locally this will have changed your git config user.name and user.email so those should be reset for this repository

Docker debug instructions

  • Install Docker and make sure docker engine is running
  • cd to the repository
  • Edit the Dockerfile to enable interactive docker debug as instructed in the comments of the file
  • docker build -t test .
  • docker run -it test
  • Now you should be at a command prompt inside your docker container and you can begin debugging

License

MIT

automatic-contrib-prs's People

Contributors

arjunsharda avatar dependabot[bot] avatar zkoppert avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.