Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 2, 2023. It is now read-only.

Conversation

@arizonaherbaltea
Copy link

@arizonaherbaltea arizonaherbaltea commented Feb 28, 2021

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.

Herbert Origas added 2 commits February 28, 2021 16:40
…en 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.
@arizonaherbaltea arizonaherbaltea changed the title feat: … Major improvements and resolutions to most open issues. Mar 1, 2021
@wei
Copy link
Member

wei commented Mar 2, 2021

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

@leethree
Copy link

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

@SionAbes
Copy link

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

@wei
Copy link
Member

wei commented Mar 24, 2021

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

@wei
Copy link
Member

wei commented Dec 25, 2022

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

@allcontributors add @arizonaherbaltea for code

@allcontributors
Copy link
Contributor

@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! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants