Code Monkey home page Code Monkey logo

close-pull's People

Contributors

actions-bot avatar dependabot[bot] avatar peter-evans avatar renovate-bot avatar renovate[bot] avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

close-pull's Issues

unexpected: closing PR closes all PRs for the commit not the branch

if i have two prs:

- #1 fix: [ABC-123] do-something
- #2 invalid branch name

and they have different branches:

- #1 fix: [ABC-123] do-something
     fix/ABC-123-do-something
- #2 invalid branch name
     invalid-branch-name

But both those branches point to the same commit ref:

- #1 fix: [ABC-123] do-something
     d280cce fix/ABC-123-do-something 
- #2 invalid branch name
     d280cce invalid-branch-name

This ends up doing the following:

  • closes both PRs
  • leaves a comment on both PRs
  • deletes the invalid-branch-name branch

Expectations:

  • closes PR #2
  • leaves a comment on PR #2
  • deletes the invalid-branch-name branch

Is there something I'm missing?


Then when i run this action with:

# ./pkg/format-prtitle/action.yml

name: Enforce branch name conventions

description: This will close pull requests that do not follow the branch naming conventions

inputs:
  ValidationPattern:
    description: acceptable branch name regex
    required: false
  ValidationCommand:
    description: a command to run that returns exit code 0 for success or exit code 1 for failure
    required: false
  HelpUrl:
    description: A url to display that provides more detailed information to the user
    required: false
  GithubToken:
    description: should we use context or fetch the latest title
    required: false
    default: ${{github.token}}
  BranchName:
    description: name of the branch to test
    required: true

runs:
  using: "composite"

  steps:
    - name: Test branch with pattern
      if: inputs.ValidationPattern != '' && inputs.ValidationCommand == ''
      uses: actions/github-script@v6
      env:
        PATTERN: ${{inputs.ValidationPattern}}
        BRANCH: ${{inputs.BranchName}}
      with:
        github-token: ${{inputs.GithubToken}}
        script: |
          const validator = new RegExp(process.env.PATTERN);
          validator.test(process.env.BRANCH)
            ? process.exit(0)
            : process.exit(1);

    - name: Test brach with command
      if: inputs.ValidationPattern == '' && inputs.ValidationCommand != ''
      shell: bash
      run: ${{inputs.ValidationCommand}}

    - name: create additional information link
      if: failure()
      shell: bash
      env:
        HELP_URL: ${{inputs.HelpUrl}}
      run: |
        [ -n "${HELP_URL}" ] && {
          echo "MORE_INFORMATION='For more information see: ${HELP_URL}'" >> $GITHUB_ENV
        } || {
          echo "MORE_INFORMATION=''" >> $GITHUB_ENV
        }

    - name: Add/Update Help Comment
      if: failure()
      uses: peter-evans/close-pull@v2
      with:
        token: ${{inputs.GithubToken}}
        delete-branch: true
        comment: |
          The branch name used is invalid.

          To fix this, please rename your branch locally and open a new pull request.

          ```
          $ git branch -m <correct branch pattern>
          ```

          ${{env.MORE_INFORMATION}}

which will be run in a workflow like so:

# .github/workflows/code-review-titles.yml

name: CodeReviewTitles

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

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  Format:
    runs-on: ubuntu-latest

    permissions:
      pull-requests: write
      issues: write
      contents: read
      repository-projects: write

    steps:
      - uses: actions/checkout@v3

      - name: get branchpattern
        id: branchpattern
        uses: actions/github-script@v6
        with:
          github-token: ${{secrets.OUR_BOT_TOKEN}}
          script: return require("./.validate-branch-namerc").pattern
          result-encoding: string

      - name: Close PRs with invalid branchnames
        uses: ./pkg/enforce-branchname
        with:
          ValidationPattern: ${{steps.branchpattern.outputs.result}}
          BranchName: ${{github.head_ref}}

      - uses: ./pkg/format-prtitle
        with:
          Pattern: ${{steps.branchpattern.outputs.result}}
          GithubToken: ${{secrets.OUR_BOT_TOKEN}}

      - uses: ./pkg/setup-tooling

      - uses: ./pkg/setup-pnpm

      - uses: ./pkg/commitlint-prtitle
        with:
          InstallCommitLint: false
          FetchTitle: true
          GithubToken: ${{secrets.OUR_BOT_TOKEN}}

Allow regex matching

This is more of a feature request than anything else.

Would it be possible to have the action close all pull requests that have the titles corresponding to the Regex Match?

Would be cool and in some cases more useful than just a PR number.

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.