Skip to content

Instantly share code, notes, and snippets.

@mstijak
Last active December 8, 2021 13:31
Show Gist options
  • Save mstijak/fdb6b7621671f9442b96d3c8dbcae53d to your computer and use it in GitHub Desktop.
Save mstijak/fdb6b7621671f9442b96d3c8dbcae53d to your computer and use it in GitHub Desktop.
name: Publish PRs in the Dev branch for preview
on:
pull_request:
types: [opened, labeled, synchronize, reopened]
jobs:
merge-dev:
if: contains(github.event.pull_request.labels.*.name, 'DEV')
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.DEV_DEPLOY_TOKEN }}
- name: Merge Script
run: |
git --version
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git status
git fetch origin dev
git checkout dev
git pull
git merge origin/${{ github.head_ref }} --no-edit -m "Merge PR ${{ github.ref_name }} to the dev branch for preview"
git push
@mstijak
Copy link
Author

mstijak commented Dec 8, 2021

Custom PAT token is required if this change needs to trigger the action to actually deploy the dev branch. Otherwise, line token: ${{ secrets.DEV_DEPLOY_TOKEN }} can be omitted.

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