Skip to content

Instantly share code, notes, and snippets.

@PatelUtkarsh
Last active January 20, 2024 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatelUtkarsh/d1966b63c193a39a5e32f76e3cf12a11 to your computer and use it in GitHub Desktop.
Save PatelUtkarsh/d1966b63c193a39a5e32f76e3cf12a11 to your computer and use it in GitHub Desktop.
Auto merge PR on adding label and trigger deployment if the branch supports it. Must have PAT(Personal access token) added to GH action.
name: Auto Merge and Push on Label
on:
pull_request_target:
types: [labeled]
jobs:
auto-merge-and-push:
runs-on: ubuntu-latest
if: github.event.label.name == 'In dev'
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Merge PR
run: |
git config --global user.name 'CI'
git config --global user.email 'change-this-email@users.noreply.github.com'
git fetch origin
git checkout develop
git merge --no-ff ${{ github.head_ref }} -m "Merging PR #${{ github.event.pull_request.number }}"
git push origin develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment