Giter Club home page Giter Club logo

gh-get-current-pr's Issues

Default branch not working

Subject of the issue

Default branch not working

Your git environment

I use it with this configuration. When I try launch an action after deploy it's currently working everywhere execpt on the default branch (which is development on my project)

on:
  deployment_status:
    branches:
      - development
      - staging
      - main

Steps to reproduce

When you try to use it on a deployment_status github action it's currently not working if you are the default branch

Expected behaviour

image

Actual behaviour

image

can you add draft on outputs please

Subject of the issue

Describe your issue here.

Your git environment

  • public repo to reproduce the issue with?
  • or put detailed reproduction steps down below

Steps to reproduce

Tell us how to reproduce this issue. Please provide a working demo, you can use this template as a base.

Expected behaviour

Tell us what should happen

Actual behaviour

Tell us what happens instead

PR between forks

Subject of the issue

I may be wrong but it seems that the action does not find the corresponding PR when it is a PR across forks.

Your git environment

    - name: Get PR object
      if: failure()
      uses: 8BitJonny/[email protected]
      id: failed_pr_number
      with:
        sha: ${{ github.event.pull_request.head.sha }}
    - name: Debug GetPR output
      if: failure()
      run: |
          echo ${{ steps.failed_pr_number.outputs.number }}

Steps to reproduce

I guess just make a PR between forks should make it reproducible.

Expected behaviour

I was expecting to find the good PR number

Actual behaviour

Tell us what happens instead

Feature Proposal: Match Branch when checking for PR

if I have 2 branches, one with a PR associated with it, and one not,
and I push the same commit to both branches in github.

expected - when the action executes one of the branches should detects a PR exists and return a number, the other one should not.

actual - both branches find the same associated PR and return the same associated PR number.

this makes using this scheme kinda dangerous, as side-effects - publishing, overwriting pre-release artifacts etc will occur from unexpected branches.

a convenience option to compare the head.label or ref with the current branch would be very helpful.

Filter drafts too

Instead of just filtering open, we should be able to filter draft pull requests too.

Update to nodejs 20 (16 deprecated)

Subject of the issue

GitHub urges all actions to update nodejs to 20

I'm putting this up here for now, can probably submit a pr in a while..:P

Get proper test setup going

What

This Repo is slowly growing and getting more and more used. A proper testing workflow integrated into the CI is more that overdue

Outcome Always Success?

Subject of the issue

Clarification on documentation. I am wondering if I am interpreting it correctly that if the outcome of the action is that the commit is NOT part of a PR, it will not return success?

In my testing, it is returning success regardless of it a PR exists. So using the conditional if: steps.PR.outcome == 'success' doesn't really help me in directing things depending on if it is a PR or not.

I am able to use this how I need it by focusing on the pr number output, however the outcome being successful seems strange to me?

thanks for creating this!

Your git environment

using a self-hosted github runner in github enterprise v3.7 (latest)

Steps to reproduce

In theory this should work everywhere and not require my environment. My workflow is below.

Expected behaviour

If commit is not part of a PR, action will not return success

Actual behaviour

success is returned regardless. However the PR information outputs are empty.

Workflow:

name: Workflow

on:
  push:
    branches-ignore:
      - main

# stops current jobs if a new commit is pushed to the branch
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

PR:
    runs-on: [dev, terraform]
    outputs:
      PR_STATUS: ${{ steps.pr-check.outputs.PR_STATUS }}
      PR_NUMBER: ${{ steps.PR.outputs.number }}
      PR_OUTCOME: ${{ steps.PR.outcome }}
    steps:
      - uses: synced-actions/[email protected]
        id: PR
      - id: pr-check
        run: |
          if [ ${{ steps.PR.outputs.number }} == 0 ]; then
            echo "PR_STATUS=false" >> $GITHUB_OUTPUT
          else
            echo "PR_STATUS=true" >> $GITHUB_OUTPUT
          fi

  test:
    needs: PR
    runs-on: [dev, terraform]
    steps:
      - run: |
          echo "Status:" ${{ needs.PR.outputs.PR_STATUS }} and Number: ${{ needs.PR.outputs.PR_NUMBER }}""
      - if: needs.PR.outputs.PR_STATUS == true
        run: |
          echo "TRUE PR status is ${{ needs.PR.outputs.PR_STATUS }}"
      - if: needs.PR.outputs.PR_STATUS != true
        run: |
          echo "FALSE PR status : ${{ needs.PR.outputs.PR_STATUS }}"
      - if: needs.PR.outputs.PR_NUMBER == 0
        run: |
          echo "empty PR NUMBER : ${{ needs.PR.outputs.PR_NUMBER }}"
      - if: needs.PR.outputs.PR_NUMBER != 0
        run: |
          echo "existing PR NUMBER is ${{ needs.PR.outputs.PR_NUMBER }}"

pr_title includes commits:

I am using this in conjunction with rtCamp/action-slack-notify@v2 and the PR title is showing all of the commits:

image

When a user merges the pr, the commits are automatically included. Can they be removed or should I handle this manually

node_modules is not committed

When I run the workflow I get the following error because the node_modules folder is not committed to the action's repository:

internal/modules/cjs/loader.js:800
    throw err;
    ^

Error: Cannot find module '@actions/core'
Require stack:
- /home/runner/work/_actions/8BitJonny/gh-get-current-pr/1.0.0/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/work/_actions/8BitJonny/gh-get-current-pr/1.0.0/index.js:7:44)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/work/_actions/8BitJonny/gh-get-current-pr/1.0.0/index.js'
  ]
}

Could you please commit the node_modules as well?

Error reading JToken from JsonReader. Path '', line 0, position 0.

Subject of the issue

Trying to get this action to work although I either get an empty JSON or an error.

Your git environment

I've added in my action file below

name: Pull Request Lint

on:
  pull_request:
    types: ['opened', 'edited', 'synchronize', 'reopened']

jobs:
  pr_linter:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - name: Lint branch name and PR title
        uses: aschbacd/[email protected]
        with:
          commit-message-subject-max-length: 100
          re-commit-message-subject: .*
          re-branch-name: '^[0-9]{4}-'
          re-pull-request-title: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)'

      - name: Get branch name
        id: branch-name
        uses: tj-actions/branch-names@v6
      
      - name: Running on a pull request branch.
        id: extract_branch
        if: steps.branch-name.outputs.is_default == 'false'
        run: |
          echo "Running on pr: ${{ steps.branch-name.outputs.current_branch }}"
          echo "branch_name=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV

      - name: step1
        id: step1
        run: echo 'step_1_json={"a":1}' >> $GITHUB_ENV
        if: true

      - name: step2
        run: echo $A && echo $B && echo $C
        env:
          A: ${{ env.step_1_json && fromJSON(env.step_1_json).a }}
          B: ${{ env.step_1_json }}
          C: ${{ fromJSON(env.step_1_json).a }}
        if: true

      - uses: 8BitJonny/[email protected]
        id: PR
        with:
          sha: ${{ github.event.pull_request.head.sha }}

      - run: echo "PR ${prNumber} ${prTitle} at ${prUrl}"
        if: steps.PR.outcome == 'success'
        env:
          # TODO: try and get JSON object with the full PR object working
          # toJSON(fromJSON(...pr)) parses it into memory and then format is with pretty-print.
          prJSON: ${{ toJSON(fromJSON(steps.current_pr.outputs.pr)) }}
          # Direct access to common PR properties
          prNumber: ${{ steps.PR.outputs.number }}
          prUrl: ${{ steps.PR.outputs.pr_url }}
          prTitle: ${{ steps.PR.outputs.pr_title }}
          prBody: ${{ steps.PR.outputs.pr_body }}
          prCreatedAt: ${{ steps.PR.outputs.pr_created_at }}
          prMergedAt: ${{ steps.PR.outputs.pr_merged_at }}
          prClosedAt: ${{ steps.PR.outputs.pr_closed_at }}
          prLabel: ${{ steps.PR.outputs.pr_labels }}
        
        
      - if: ${{ steps.PR.outputs.pr_body }} != 'Fixed AB#${{ env.branch_name }}'
        uses: DerekRoberts/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          # add_markdown: Fixed AB#${{ env.branch_name }}

Steps to reproduce

Run the action

Expected behaviour

It does not error and I get a JSON back

Actual behaviour

I get an error and/or empty JSON returned.

image

Resource not accessible by integration

Subject of the issue

The action is not working

Your git environment

I have a step that is like that:

      - name: Fetch PR
        if: ${{ github.event.pull_request }}
        uses: 8BitJonny/[email protected]

      - name: Rebase PR with target
        if: ${{ github.event.pull_request }}
        run: |
          git rebase $GITHUB_BASE_REF
          git log $GITHUB_BASE_REF..HEAD --pretty=format:"%h - %s (%an)"

image

Expected behaviour

To fetch the current PR

Actual behaviour

It's failing

the action doesn't not return data on closed pr

Subject of the issue

the action doesn't return api data on closed pr event

Your git environment

I have two github jobs one is to get the data using this repo action and one is a job that triggered when a pr is closed

jobs:
  get-pr:
    runs-on: ubuntu-latest
    outputs:
      PR: ${{steps.PR.outputs.pr}}
    steps:
      - name: Find Pull Request
        uses: 8BitJonny/[email protected]
        id: PR
        with:
          sha: ${{ github.event.pull_request.head.sha }}

closed_by_user:
    timeout-minutes: 30
    needs: get-pr
    if:  needs.get-pr.outputs.PR != '' && github.event.pull_request.merged == false && github.event.pull_request.closed
    runs-on: ubuntu-latest
    steps: 
         .....

Steps to reproduce

with the following if condition on the job

needs.get-pr.outputs.PR != '' && github.event.pull_request.merged == false && github.event.pull_request.closed

Expected behaviour

needs.get-pr.outputs.PR return json data , the job will triggered

Actual behaviour

the closed_by_user jobs didn't run because the needs.get-pr.outputs.PR didn't return any json data

when I removed the needs.get-pr.outputs.PR != '' the job is triggered, but got error since I need a data from the API, but the data is empty

If you create a PR with ( ) in the title it breaks the process

Subject of the issue

I created a PR with the title: fix!: Something (something)

Your git environment

It's a closed repo

Steps to reproduce

Create a PR with (or ) in the title and try to call. I didn't check for other special chars

      - name: Information
        run: |
          echo Base PR URL: ${{ steps.PR.outputs.pr_url }}
          echo Based On PR Title: ${{ steps.PR.outputs.pr_title }}

Expected behaviour

Should output the info about the PR

Actual behaviour

Run echo Base PR URL: https://github.com/***/pull/22
/home/runner/work/_temp/547790f0-2141-4ff[8](https://github.com/***o/runs/7837860134?check_suite_focus=true#step:6:9)-b1b6-5d0fdf8883c8.sh: line 2: syntax error near unexpected token `('
Base PR URL: https://github.com/****/pull/22
Error: Process completed with exit code 2.

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.