Giter VIP home page Giter VIP logo

slash-command-action's Introduction

Slash Commands Action

CI CodeQL codecov

Check issue or pull request comments for /commands and trigger or block workflows based on them.

Usage

In the following example comments will be checked for the command /test (parameters are optional such as /test ui) and will only pass if the user who left the comment has admin access to the repo. It will only run on the initial comment, not on edits, and when the action runs it will add a reaction of ๐Ÿ‘€ to the comment indicating it was seen.

on: issue_comment
name: Issue Comments
permissions:
  issues: write
jobs:
  check_comments:
    name: Check comments for /test
    runs-on: ubuntu-latest
    steps:
      - name: Check for Command
        id: command
        uses: xt0rted/slash-command-action@v1
        with:
          command: test
          reaction: "true"
          reaction-type: "eyes"
          allow-edits: "false"
          permission-level: admin
      - name: Act on the command
        run: echo "The command was '${{ steps.command.outputs.command-name }}' with arguments '${{ steps.command.outputs.command-arguments }}'"

Options

Required

Name Allowed values Description
repo-token GITHUB_TOKEN (default) or PAT GITHUB_TOKEN token or a PAT.
command [a-zA-Z0-9_] The command to act on. You can test how your command will be parsed here.

Optional

Name Allowed values Description
reaction true (default), false Indicates if a reaction is left on the comment indicating it was seen.
reaction-type +1 (default), -1, laugh, confused, heart, hooray, rocket, eyes The reaction type to leave on the comment.
allow-edits true, false (default) Indicates if the action should run on comment edits, or the initial comment only.
permission-level admin, write (default), read, none The user's permission level needed to act on the command.

License

The scripts and documentation in this project are released under the MIT License

slash-command-action's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar dependamerge[bot] avatar mozgiii avatar xt0rted avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

slash-command-action's Issues

readme example

I just copy pasted that example in the readme and it doesn't work.

a) the steps is nested incorrectly
b) its missing the runs-on attr

Do not fail on every non-slash command

Currently, the task fails for every non-slash command, making the regular discussions on the PR impossible due to email spam from Github Actions.
Can we figure out a workaround for it?

Allow using `@` instead of `/`

Using @ instead of / would let you simulate mentioning github apps/bots. So instead of /do something you could do @some-bot do something.

Depends on #759

Support for collaborator roles

The Triage and Maintain roles need to be added. It looks like these aren't returned from the rest api, so this call will need to be switched to graphql.

Get branch ref for pr comments and set it as an output value

When the issue_comment event is triggered on a PR the action payload is for the default branch not the PR branch. Because of this we need to do some magic to get the PR branch info and pass it along to the next action.

The idea is to do something like so:

on:
  issue_comment:
    types: created

jobs:
  lint:
    steps:
      - name: Check for Command
        id: command
        uses: xt0rted/[email protected]
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          command: lint

      - name: Checkout Repo
        uses: actions/checkout@v1
        with:
          ref: ${{ steps.command.outputs.branch-ref }}

Allow `-` in the command

The regex being used matches a-zA-Z0-9_. Updating this to include - will let you match usernames which can't be done currently. Usernames have the following criteria:

  • Must start with a-zA-Z0-9
  • Can contain multiple - but not consecutively
  • Must end with a-zA-Z0-9

This is the current regex:

/^\/([\w]+)\b *(.*)?$/m

And this is what I'm thinking of switching to:

/^\/([a-zA-Z0-9]+(?:[-_][a-zA-Z0-9]+)*) *(.*)?$/m

Adding a reaction with insufficient permissions doesn't throw an error or log a warning

Depending on if the action is used on issues or pull requests the GITHUB_TOKEN or PAT needs issues: write or pull_requests: write permissions in order to add reactions. If the token doesn't have sufficient permission the code tries to add the reaction, and continues on even if it failed. This should at least check for the bad response and report an error but ideally it'd throw and not continue on.

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.