GithubHelp home page GithubHelp logo

rickihastings / event-parser-actions Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 151 KB

A Github action for parsing Github event (or any input data) and returning the data for use in other actions and steps.

License: MIT License

TypeScript 100.00%

event-parser-actions's Introduction

Event Parser Github Action

This action parses an input of choice, such as something from the Github Event API, eg: {{ github.event.comment.body }}, and attempts to parse key=value tokens from the input and output them as variables.

Unless you lock this down somehow it's wise to only use it on private repositories for now.

Happy to accept PRs to optionally check CODEOWNERS, or something similar.

Why?

This can be used to optionally trigger workflows when a user comments in a PR, for example you may want to trigger a test deployment, or run a specific test suite.

An example of a comment could be:

+deploy env=test url=hello.world.test.com

or

+tests browser=chrome

Input

source

Required The input to parse, eg ${{ github.event.comment.body }}

variables

Required A list of the variables you wish to parse separated by a new line. Or just a single variable.

Example Usage

name: Pull Request Comment Trigger Example
on:
  issue_comment:
    types: [created]

jobs:
  test_job:
    runs-on: ubuntu-latest
    name: An example workflow on comment
    if: contains(github.event.comment.body, '+deploy') && github.event.issue.pull_request
    steps:
      - name: Extract vars
        uses: ./
        id: vars
        with:
          source: ${{ github.event.comment.body }}
          variables: |
            env
            url
      - name: Do something with env vars...
        run: |
          echo ${{ steps.vars.outputs.env }}
          echo ${{ steps.vars.outputs.url }}

Local development

  1. Make changes to index.ts
  2. Rebuild with yarn build
  3. Test your changes yarn test

Licence

MIT

event-parser-actions's People

Contributors

rickihastings avatar

Stargazers

 avatar

Watchers

 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.