Skip to content

Update .github/workflows/pull_request_closed.yml #1614

Update .github/workflows/pull_request_closed.yml

Update .github/workflows/pull_request_closed.yml #1614

name: Pull Request Closed
on:
pull_request:
branches: [master]
types: [closed]
jobs:
cherry_pick:
if: ${{github.event.pull_request.merged == true}}
runs-on: ubuntu-22.04
steps:
- name: Should create PR to production?
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e
id: fc
with:
issue-number: ${{github.event.number}}
body-includes: "- [x] create PR to production"
- name: checkout
if: steps.fc.outputs.comment-id != ''
uses: actions/checkout@v2
with:
token: '${{ secrets.GITHUB_TOKEN }}'
ref: production
clean: true
fetch-depth: 0
- name: Cherry-pick commits
if: steps.fc.outputs.comment-id != ''
id: cp
run: |
# Setup git and create cherry-pick branch
git config user.name ${{github.actor}}
git config user.email ${{github.actor}}@github.com
BRANCH_NAME=${{github.head_ref}}-${{github.event.number}}
git checkout -b ${BRANCH_NAME}
commits=$(git log origin/master..origin/${{github.head_ref}} --pretty=format:"%h" --reverse)
git cherry-pick $commits
git push -u origin ${BRANCH_NAME}
git checkout production
git branch -D ${BRANCH_NAME}
echo "##[set-output name=branch;]$(echo ${BRANCH_NAME})"
- name: Failed cherry-pick
if: ${{ failure() }}
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
issue-number: ${{github.event.number}}
body: |
Automatic cherry-pick & PR to production failed. Ping @telerik/blazor-admins for manual cherry-pick and push to production.
- name: pull-request
id: pr
if: steps.fc.outputs.comment-id != ''
uses: actions/checkout@v3
with:
token: '${{ secrets.GITHUB_TOKEN }}'
run: |
gh pr create --base production --head ${{ steps.cp.outputs.branch }} --title "Merge ${{ steps.cp.outputs.branch }} into production" --body "Automatically generated PR from master branch: #${{github.event.number}}. Once the change is merged, upload the changes to LIVE."
- name: Post PR link
if: steps.pr.outputs.pr_url != ''
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
issue-number: ${{github.event.number}}
body: |
Here you are the link to your PR to production: [${{steps.pr.outputs.pr_number}}](${{steps.pr.outputs.pr_url}})
delete_branch:
needs: [cherry_pick]
if: always()
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v2
with:
token: '${{ secrets.GITHUB_TOKEN }}'
- name: Delete branch
run: |
git push origin --delete ${{github.head_ref}}