Unverified Commit 228a5423 authored by AustinSanders's avatar AustinSanders Committed by GitHub
Browse files

Automate a cherrypick PR into the latest feature branch (#4615)



* Initial action to cherrypick bugfixes into PR to latest release branch

* Added comments

* Replaced tab characters with spaces

* Enabled dry run

Co-authored-by: default avatarAustin Sanders <arsanders@ugs.gov>
parent 9c9a63e2
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
name: Cherrypick bugfixes to release branch
on:
  push:
    branches:
      - dev
jobs:
  # Check if the PR is a bugfix
  check_labels:
    runs-on: ubuntu-latest
    name: Check PR labels action step
    # Make the output of this job available to other jobs
    outputs: 
      result: ${{steps.check_pr_labels.outputs.result}}
    steps:
    - id: check_pr_labels
      uses: 3pointer/check-pr-labels-on-push-action@v1.0.3
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        labels: '["bug"]'
    # Print the result to the log
    - name: See result
      run: echo "${{ steps.check_pr_labels.outputs.result }}"
  release_pull_request:
    needs: check_labels
    # Only run this step if the code was a bugfix
    if: contains(needs.check_labels.outputs.result, 'true')
    runs-on: ubuntu-latest
    name: release_pull_request
    steps:
    - name: checkout
      uses: actions/checkout@v2.2.0
      # Fetch all info including branches + tags
      with:
        fetch-depth: 0
    - name: 'Get Previous tag'
      id: get_latest_tag
      uses: "WyriHaximus/github-action-get-previous-tag@v1"
    - id: get_short_version
      # Get the major / minor version without patch info i.e. 6.0 from 6.0.1
      run: |
        major_minor=$(echo ${{steps.get_latest_tag.outputs.tag}} | cut -d '.' -f 1,2)
        echo "::set-output name=major_minor::$major_minor"
    - name: Create PR to branch
      uses: adamtharani/github-action-cherry-pick@master
      # PR to the latest feature release.  Merges are enabled
      with:
        pr_branch: ${{steps.get_short_version.outputs.major_minor}}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        DRY_RUN: true