Dad Joke #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Merge on Comment | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.event.issue.pull_request && contains(github.event.comment.body, '/merge') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- name: Merge | |
run: | | |
curl -H "Authorization: token ${{ secrets.GH_PAT }}" ${{ github.event.issue.pull_request.url }} > pr_props.json | |
HEAD_REF=$(cat pr_props.json | jq .head.ref | sed 's@"@@g') | |
BASE_REF=$(cat pr_props.json | jq .base.ref | sed 's@"@@g') | |
echo "HEAD REF IS $HEAD_REF" | |
echo "BASE REF IS $BASE_REF" | |
echo "Merge..." | |
git config --local user.email ${{ vars.USER_EMAIL }} | |
git config --local user.name ${{ vars.USER_NAME }} | |
git log -1 | |
git fetch --all | |
git checkout $BASE_REF | |
git merge --squash --ff-only origin/$HEAD_REF | |
git push origin HEAD:$BASE_REF || true | |
echo "Merge Done" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} |