GithubHelp home page GithubHelp logo

capture-url-from-issue-comment's Introduction

Overview

Capture a URL from github issue comment and feed it into your next GitHub action.

  1. This action should run whenever an edit is made to a pull request comment (see example.yml below).
  2. It checks whether the editor of the comment is from specific bot on GitHub.
  3. It attempts to extract the URL from the comment and sets it as the action's output so that you can feed it into your next action.

Please note:

  • This action only succeeds when a URL was found, it gets cancelled (if GITHUB_TOKEN is passed) or fails on every other event.
  • This action will keep executing for every edit (if following issue_comment.edited trigger). When a new commit is pushed, a bot may edit the comment again, triggering this action. Please ensure you're building in logic into your next action to handle this.

Inputs

  • cancel_pattern: Regular expression pattern to cancel the action when comment contains this pattern.
  • GITHUB_TOKEN: Pass this (as ${{secrets.GITHUB_TOKEN}}) to cancel actions instead of failing them.
  • url_pattern: Regular expression pattern to capture the URL. Ensure first capture group captures the URL.
  • user_name: The name of the action commenting on pull requests.

Outputs

Example

The example below captures the URL and comments with it on the pull request.

name: Capture URL

on:
  issue_comment:
    types: [edited]

jobs:
  capture_url:
    name: Capture URL
    runs-on: "ubuntu-latest"
    steps:
      - uses: deriv-com/capture-url-from-issue-comment@master
        id: capture_url
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      # Below is merely an example of what you could do with the URL.
      # The URL is accessed through ${{ steps.capture_url.outputs.url }}
      - uses: actions/github-script@v3
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            github.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: 'The URL is: ${{ steps.capture_url.outputs.url }}.'
            });

capture-url-from-issue-comment's People

Contributors

balakrishna-deriv avatar

Watchers

Tom Molesworth avatar  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.