pull-request icon indicating copy to clipboard operation
pull-request copied to clipboard

Major improvements and resolutions to most open issues.

Open arizonaherbaltea opened this issue 4 years ago • 4 comments

Highlights

  • adds numerous features, namely; better argument construction when passed to the 'hub' cli so that double and single quotes are appropriately handled.
  • github action grouping of console prints for easier troubleshooting and status indication, more console prints with better details regarding internal state, bash set -x debugging parameter.
  • generalize the "GITHUB_TOKEN" so Personal Action Tokens may be used as well, add support for 3rd party or repositories that are currently checked out.
  • improved 'hub' cli error handling so that the action stops and errors when the pull-request fails to create.
  • duplicate pull request handling where the head and base or destination and source branches are the same and in this case the action continues and finds the PR url and PR number.

Since this introduces so many changes a more robust test of the other parameters may need to be conducted.

Example 1

Here is an example that shows double quotes in the PR body are handled properly.

env:
  MAIN_TRACKING_BRANCH: 'main'
jobs:
  draft-new-release:
    name: "Draft a new release"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: "Determine Next Release Version"
        id: ver
        run: |
          echo "::set-output name=version-after::0.1.0"
      - name: Create Release Pull-Request
        uses: ./.github/actions/actions-create-pull-request
        with:
          source_branch: 'release/${{ steps.ver.outputs.version-after }}'
          destination_branch: '${{ env.MAIN_TRACKING_BRANCH }}'
          repository: ${{ github.repository }}
          pr_title: "Pulling 'release/${{ steps.ver.outputs.version-after }}' into master"
          pr_body: |
            :crown: *An automated PR*
            
            This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
            The Changelog and version have been updated to reflect based on the angular commits for this release.
            Merging this PR will create a GitHub release and upload any assets that are created as part of the release build, and deploy related apps and services.

            "Put a description here"
          pr_label: "release"
          pr_allow_empty: false
          token: ${{ secrets.ACTIONS_WORKFLOW_PAT }}
          debug: false

image image image

Example 2

This is what happens when a pull-request is created, but one with the same base and head branches already exists. image

Example 3

How to open a pull-request to a repo which is different from the one currently checked out. Note the use of a Github Personal Action Token during code checkout.. Even though the pull-request is being performed on another repo, a PAT with rights to the other repo is needed to successfully create the pr. The default GITHUB_TOKEN that the checkout action uses is insufficient!

jobs:
  draft-new-pr:
    name: "Create PR in action-gitflow-workflow"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
          token: ${{ secrets.ACTIONS_WORKFLOW_PAT }}
      - name: Create Alt Repo Pull-Request
        uses: ./.github/actions/actions-create-pull-request
        with:
          source_branch: 'develop'
          destination_branch: 'master'
          repository: '${{ github.repository_owner }}/actions-gitflow-workflow'
          pr_title: "Pulling 'release/${{ steps.ver.outputs.version-after }}' into master"
          pr_body: |
            :crown: *An automated PR*
            
            This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
            ..And creates a pr in this other repo here: https://github.com/${{ github.repository_owner }}/actions-gitflow-workflow.

            "Put a description here"
            'Quotes are being handled'
            ""''""'' '""''' '" '' '""""'"'
            ''\'''|'"\"""
            Quote monster ^^^^^^
          pr_label: "some-label,another-label"
          pr_assignee: "herbaltealeaf"
          pr_allow_empty: false
          token: ${{ secrets.ACTIONS_WORKFLOW_PAT }}
          debug: false

image image image

Note

These changes are as is. I've improved upon this pull-request action for use with my org and am sharing the results of that labor here. Merge it, don't merge it, agree, don't agree, edit the pr, fork the fork, whatever. Its all good. I don't really care.

However if you are seeing bugs, let me know so it can be fixed.

arizonaherbaltea avatar Feb 28 '21 23:02 arizonaherbaltea

👋 @herbaltealeaf Thanks so much for your contribution. We will review it and publish a new major release version once approved.

wei avatar Mar 02 '21 18:03 wei

this looks nice. any chance we can get this merged soon?

leethree avatar Mar 22 '21 15:03 leethree

Yeah pretty excited about these changes, would love to roll them out to our productive systems. Any chance of an ETA?

SionAbes avatar Mar 24 '21 09:03 SionAbes

@leethree @SionAbes Perhaps you guys can help test for backwards compatibility and new features

wei avatar Mar 24 '21 12:03 wei

Hi there thank you for the amazing PR, I have incorporated a number of the changes in #117

@allcontributors add @arizonaherbaltea for code

wei avatar Dec 25 '22 02:12 wei

@wei

I couldn't determine any contributions to add, did you specify any contributions? Please make sure to use valid contribution names.

I've put up a pull request to add @arizonaherbaltea! :tada:

allcontributors[bot] avatar Dec 25 '22 02:12 allcontributors[bot]