GithubHelp home page GithubHelp logo

benbalter / bulk-issue-creator Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 0.0 2.41 MB

Bulk opens batches of issues (or posts comments) across GitHub repositories based on a template and CSV of values. Think of it like "mail merge" for GitHub issues.

License: MIT License

Shell 0.40% JavaScript 10.85% TypeScript 88.40% Mustache 0.07% Liquid 0.28%

bulk-issue-creator's Introduction

GitHub bulk issue creator

Bulk opens batches of issues (or posts comments) across GitHub repositories based on a template and CSV of values. Think of it like "mail merge" for GitHub issues. It can be run locally, via Codespaces, or via GitHub Actions.

How it works

  1. You create a CSV of repositories where you'd like issues opened and any fill-in fields you'd like to include in the resulting issues. It might look something like this: Example CSV
  2. You create a template of what you'd like to use as the basis for the resulting issue body. You can even reference those per-issue fill-in fields. If we wanted to reference the name field in the example above, it might look something like this:
    Example template
  3. You run the bulk issue creator script (either locally, via Codespaces, or via GitHub Actions - see below)
  4. Customized issues (or comments) are created on your behalf for every row you defined in the CSV.
  5. Profit! ๐ŸŽ‰

Running locally

  1. git clone https://github.com/benbalter/bulk-issue-creator
  2. bulk-issue-creator init to create a ./config/data.csv and ./config/template.md.mustache files
  3. Follow the "Setup" instructions below to customize the data file and template.
  4. Export the personal access token you create as the GITHUB_TOKEN environmental variable, or add it to a .env file in the root of the repository in the form of GITHUB_TOKEN=XXX.
  5. Run bulk-issue-creator to preview the output
  6. Run bulk-issue-creator --write to create the issues.

Running via GitHub actions

Don't want to deal with the hassle of setting up a local Ruby environment? No worries. With a little copy/paste can use GitHub actions to open issues from the cloud!:

  1. Create a new repository (public or private)

  2. Follow the "Setup" instructions below to add the CSV and template to the repository.

  3. If you'd like to open issues in a repository other than the one containing the action, store a personal access token you create as the PERSONAL_ACCESS_TOKEN Actions Secret within the repository settings

  4. Create a .github/workflows/bulk-issue-creator.yml file with the following contents:

    on:
      workflow_dispatch:
        inputs:
          write:
            description: "Change to 'true' to create issues, leave as 'false' to preview output"
            default: "false"
            type: boolean
    
    name: Bulk issue creator
    
    jobs:
      bulk_issue_creator:
        runs-on: ubuntu-latest
        name: Bulk Issue Creator
        steps:
          - name: Checkout template and data
            uses: actions/checkout@v2
          - name: Create bulk issues
            uses: benbalter/bulk-issue-creator@v2
            with:
              write: ${{ github.event.inputs.write }}
              github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
  5. Navigate to Actions -> Bulk issue creator -> Run Workflow and click Run Workflow to preview the output. Workflow dispatch steps

    Note: once you run the workflow, you can see the output by clicking Bulk issue creator in the side bar, and then clicking into the most recent run.

    Example preview output

  6. Repeat step 5, changing the false text input to true in the final dialog to create issues.

Setup

  1. Run bulk-issue-creator init or manually create a CSV file in ./config/data.csv. The CSV must have columns for repository and title (for issues) or issue_number (for comments). All field names are case sensitive. You can also add any other columns you would like, which will be available to the template. It should look something like this:
    repository,title,project,labels
    benbalter/gman,Update GMan,GMan,"Red,Blue"
    benbalter/jekyll-auth,Update Jekyll Auth,Jekyll Auth,"Green,Blue"
    
  2. Edit (or create) the ./config/template.md.mustache file in the same directory with the content you want in the issue body. You can reference CSV fields like {{project}} using the Mustache syntax. It should look something like this:
    Hey there! It looks like it's time to update {{project}}!
  3. Create a personal access token with repo scope.

Templating

Templates (and issue titles) support the Mustache syntax syntax by default. Field names in the CSV should be lower case, and should use _s to separate multiple words like_this, instead of spaces.

Note: You can also use the slightly more advanced Liquid templating system by passing the liquid option (see below).

Advanced usage

Optional arguments

Options can be passed as command-line arguments when running locally or via the with: property of GitHub Actions. Both locally and when running via GitHub actions, options can also be passed via environment variables. See the table below for available options and how to pass them:

Command line GitHub Actions with: GitHub Actions env: Description
--write write: WRITE: Write issues to GitHub (default: false)
--comment comment: COMMENT: Create comments instead of issues
--template-path template_path: TEMPLATE_PATH: Path to the template file
--csv-path csv_path: CSV_PATH: Path to the CSV file
--liquid liquid: LIQUID: Use Liquid template engine (default: false)
--github-token github_token: GITHUB_TOKEN: GitHub Token for authenticating with GitHub

Special fields

  • You can add a labels or assignees column to the CSV, with a comma-separated list of labels or assignees that you'd like added to the issue.
  • You can add an issue_number column to the CSV, with the issue number you'd like the comment added to. Note: You must pass the --comment flag

Adding issues to a project board

If you'd like to add created issues to a project board, I suggest adding a specific label and using actions/add-to-project to add the issue to the project board.

bulk-issue-creator's People

Contributors

benbalter avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bulk-issue-creator's Issues

Issue generation job exits without completing after failure

Describe the bug

If a repository in data.csv exists but does not allow for issue creation (issues turned off, repository is archived) the job will fail at that point. Any issues in repositories before that are created, but the job exits and does not create any further issues.

I noticed that in the test run, scenarios where repositories simply do not exist seem to proceed with a warning just fine.

Steps to reproduce the behavior

  1. Use a data.csv file with a repository that exists but is not able to create an issue
  2. Note in the logs the failure, and that no subsequent issues are created

Expected behavior

The job should fail entirely or repositories should be noted in the logs, but the job should continue.

`@username` format in `assignees` column causes action to fail

Describe the bug

When the assignees column is in the form of @username, the issue generation action fails and the issue is not created. (When the column contains username, the action succeeds, the issue is created, and the username is assigned to the issue - as expected.)

Steps to reproduce the behavior

  1. Create a data.csv with a column entitled assignees and a row that populates that column with a valid username in the format of @username.
  2. Run the Bulk Issue Creator action

Expected behavior

The expectation is that the issue would be created and assigned as it is when the @ is not included in the username.

Screenshots

https://github.com/github/bulk-email-compliance/actions/runs/7802978340/job/21281673666

Additional context

In our case, we wanted to both include the username (as a mention) in the created as well as the assignee, so we used the @username format. While it would be possible to add the @ in the template rather than in the data, it just wasn't something we were expecting. If changing the behavior is not an acceptable approach, it would be good to update the documentation to describe the expected format for the assignees field.

Fatal error

Describe the bug

I am getting the following error on the bulk create issues step, am I doing something wrong?

Run benbalter/bulk-issue-creator@main
/usr/bin/docker run --name c044242be5fa4e1de4e5fa51[6](https://github.com/username/repo-name/actions/runs/4539606879/jobs/7999631349#step:4:7)bc0d2e[7](https://github.com/username/repo-name/actions/runs/4539606879/jobs/7999631349#step:4:8)d1bd9_1e[8](https://github.com/username/repo-name/actions/runs/4539606879/jobs/7999631349#step:4:9)807 --label 6c0442 --workdir /github/workspace --rm -e "GITHUB_TOKEN" -e "INPUT_WRITE" -e "INPUT_COMMENT" -e "INPUT_TEMPLATE_PATH" -e "INPUT_CSV_PATH" -e "INPUT_GITHUB_TOKEN" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/repo-name/repo-name":"/github/workspace" 6c0442:42be5fa4e1de4e5fa516bc0d2e7d1bd[9](https://github.com/username/repo-name/actions/runs/4539606879/jobs/7999631349#step:4:10)  "false" "" "" "" ""
fatal: not a git repository (or any of the parent directories): .git
To use retry middleware with Faraday v2.0+, install `faraday-retry` gem
/usr/src/app/lib/bulk_issue_creator.rb:[10](https://github.com/username/repo-name/actions/runs/4539606879/jobs/7999631349#step:4:11)4:in `ensure_path_exists': Expected /github/workspace/config/template.md.mustache to exist (BulkIssueCreator::MissingFileError)
	from /usr/src/app/lib/bulk_issue_creator.rb:64:in `run'
	from /usr/src/app/bin/bulk-issue-creator:21:in `create'
	from /usr/local/bundle/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	from /usr/local/bundle/gems/thor-1.2.1/lib/thor/invocation.rb:[12](https://github.com/username/repo-name/actions/runs/4539606879/jobs/7999631349#step:4:13)7:in `invoke_command'
	from /usr/local/bundle/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	from /usr/local/bundle/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
	from /usr/src/app/bin/bulk-issue-creator:51:in `<main>'
I, [[20](https://github.com/username/repo-name/actions/runs/4539606879/jobs/7999631349#step:4:21)23-03-28T05:28:59.40[22](https://github.com/username/repo-name/actions/runs/4539606879/jobs/7999631349#step:4:23)02 #8]  INFO -- : Running with the following options:
---
template_path: 
csv_path: 
write: false
comment: false

`

Steps to reproduce the behavior

Follow the instructions (just doing1 repository, so no API key)

Github Workflow Action fails to set true state.

Setup

  • Setup IAW instructions, with a data.csv and template.md.mustache located at ./config and personal access token generated on the repo I'm trying to send issues to, and the secret variable set to the token on the repo I'm running the workflow from.

Logs

  • Note: this is from the version where I just directly applied the variables in the workflow, but the standard one that I needed to check the box to make the write: true still showed the same initial info.
Run benbalter/bulk-issue-creator@main
  with:
    write: true
    comment: false
    template_path: ./config/template.md.mustache
    csv_path: ./config/data.csv
    github_token: ***
/usr/bin/docker run --name ed866e1d89770[2](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:2)11494e06bf7b9daae2ab91eb_761e[3](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:3)[4](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:4) --label ed866e --workdir /github/workspace --rm -e "INPUT_WRITE" -e "INPUT_COMMENT" -e "INPUT_TEMPLATE_PATH" -e "INPUT_CSV_PATH" -e "INPUT_GITHUB_TOKEN" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/OH-Bulk-Issue-Generation/OH-Bulk-Issue-Generation":"/github/workspace" ed866e:1d89770211494e06bf7b9daae2ab91eb  "true" "false" "./config/template.md.mustache" "./config/data.csv" "***"
fatal: not a git repository (or any of the parent directories): .git
To use retry middleware with Faraday v2.0+, install `faraday-retry` gem
I, [2023-0[5](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:5)-17T18:35:59.0[6](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:6)6060 #8]  INFO -- : Running with the following options:
---
template_path: 
csv_path: 
write: false
comment: false

I, [2023-05-1[7](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:7)T1[8](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:9):35:5[9](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:10).066[14](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:15)7 #8]  INFO -- : Running in READ ONLY mode. Pass `WRITE=true` environmental variable to create issues.
I, [2023-05-17T18:35:59.066[16](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:17)0 #8]  INFO -- : The following issues would be created:


I, [2023-05-[17](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:18)T[18](https://github.com/jrsteensen/OH-Bulk-Issue-Generation/actions/runs/5006734800/jobs/8972396530#step:4:19):35:59.187495 #8]  INFO -- : ---
repository: jrsteensen/OpenHornet
...

Logging indicates only one issue was created where multiple were

Describe the bug

When looking at the output log from my most recent workflow run, it indicates only one issue was created. I confirmed in my other target repos from my data.csv, and those issues were indeed created.

Steps to reproduce the behavior

  1. Look at the workflow output from this job run. This indicates only one issue in /torched-marshmallows was created.
  2. In my data.csv file, /issues-graph was another target repo, along with several others.
  3. Observe this issue was indeed created, but it does not show in the log from that workflow run.

Expected behavior

The output logging should note all repos that issues were created or updated in.

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.