GithubHelp home page GithubHelp logo

kareemmax / pull-request-comment-branch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xt0rted/pull-request-comment-branch

0.0 0.0 1.0 720 KB

A GitHub Action to get the head ref and sha of a pull request comment

License: MIT License

TypeScript 100.00%

pull-request-comment-branch's Introduction

Pull Request Comment Branch

CI CodeQL

Get the head ref and sha of a pull request comment.

Workflows for pull request comments are triggered using the issue_comment event which runs for both issues and pull requests. This action lets you filter your workflow to comments only on pull requests. It also gets the head ref and sha for the pull request branch which can be used later in the workflow.

The pull request head ref and sha are important because issue_comment workflows run against the repository's default branch (usually main or master) and not the pull request's branch. With this action you'll be able to pass the ref to actions/checkout and work with the pull request's code.

Usage

on:
  issue_comment:
    types: [created]

jobs:
  pr-comment:
    runs-on: ubuntu-latest
    steps:
      - uses: xt0rted/pull-request-comment-branch@v2
        id: comment-branch

      - uses: actions/checkout@v2
        if: success()
        with:
          ref: ${{ steps.comment-branch.outputs.head_ref }}

      - run: git rev-parse --abbrev-ref HEAD
      - run: git rev-parse --verify HEAD

Token Permissions

If your repository is using token permissions you'll need to set contents: read, issues: read and pull-request: read on either the workflow or the job.

Workflow Config

on: issue_comment
permissions:
  contents: read
  issues: read
  pull-requests: read
jobs:
  pr-comment:
    runs-on: ubuntu-latest
    steps:
      - uses: xt0rted/pull-request-comment-branch@v2

Job Config

on: issue_comment
jobs:
  pr-comment:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      issues: read
      pull-requests: read
    steps:
      - uses: xt0rted/pull-request-comment-branch@v2

Options

Required

Name Allowed values Description
repo_token GITHUB_TOKEN (default) or PAT GITHUB_TOKEN token or a repo scoped PAT.

Outputs

Name Decription
base_ref The name of the branch the pull request will merge into.
base_sha The head sha of the branch the pull request will merge into.
head_ref The name of the pull request branch the comment belongs to.
head_sha The head sha of the pull request branch the comment belongs to.

License

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

pull-request-comment-branch's People

Contributors

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

Forkers

bitswamp

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.