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

Automation on Assignees of Issues/PR #63

Open
derskythe opened this issue Apr 9, 2023 · 2 comments
Open

Automation on Assignees of Issues/PR #63

derskythe opened this issue Apr 9, 2023 · 2 comments
Assignees
Labels
ci/cd Automated PRs enhancement New feature or request

Comments

@derskythe
Copy link
Owner

Need to add workflows/actions for such purpose

@derskythe derskythe added enhancement New feature or request ci/cd Automated PRs labels Apr 9, 2023
@derskythe derskythe self-assigned this Apr 9, 2023
@derskythe
Copy link
Owner Author

Labeling pull request

RegEx Issue Labeler

Issue labeler

Assign

Can't find good one, but find this repo: https://github.com/abinoda/assignee-to-reviewer-action
Latest activity 4 years ago, Node12 but TS.
We can fork or make compilation from different repos to make uber solution all-in-one.

@derskythe
Copy link
Owner Author

This is all non-boiler code in Assign.
index.js file in dist looks like standard lib of GitHub

import * as github from '@actions/github';
import * as core from '@actions/core';

async function run(): Promise<void> {
  try {
    const githubToken = core.getInput('github_token', { required: true });

    const assignees = core
      .getInput('assignees')
      .split('\n')
      .filter(l => l !== '');
    const [owner, repo] = core.getInput('repo').split('/');
    const number =
      core.getInput('number') === ''
        ? github.context.issue.number
        : parseInt(core.getInput('number'));

    const client = new github.GitHub(githubToken);
    await client.issues.addAssignees({
      assignees,
      owner,
      repo,
      issue_number: number
    });
  } catch (e) {
    core.error(e);
    core.setFailed(e.message);
  }
}

run();

action.yml

name: Actions Ecosystem Action Add Assignees
description: Add assignees to an issue or a pull request
author: Actions Ecosystem
inputs:
  github_token:
    description: A GitHub token.
    required: true
  assignees:
    description: The assignees' name to be added. Must be separated with line breaks if there're multiple assignees.
    required: true
  repo:
    description: The owner and repository name. e.g.) Codertocat/Hello-World
    required: false
    default: ${{ github.repository }}
  number:
    description: The number of the issue or pull request.
    required: false
runs:
  using: node12
  main: dist/index.js
branding:
  icon: users
  color: green

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

No branches or pull requests

1 participant