Skip to content

Commit

Permalink
Auto PR with Auto merge for syncing master-v2 (#1604)
Browse files Browse the repository at this point in the history
* feat: auto pr for master-v2

* feat: auto merge pr's without conflicts
souradeep-das authored Jun 30, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b23471a commit cbece84
Showing 2 changed files with 69 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/auto-merge-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Auto Merge PR without conflicts

on:
pull_request:
branches: [ master-v2 ]

jobs:
auto-merge-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Attach Label to PR
run: |
set -o xtrace
curl -X PATCH "https://api.github.com/repos/omgnetwork/elixir-omg/issues/${{ github.event.pull_request.number }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.HOUSE_KEEPER_BOT_TOKEN }}" \
--data "{\"labels\": [\"sync master-v2\"]}"
- name: Merge PR
if: github.head_ref == 'master'
run: |
set -o xtrace
function check_merge() {
curl "https://api.github.com/repos/omgnetwork/elixir-omg/pulls/${{ github.event.pull_request.number }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.HOUSE_KEEPER_BOT_TOKEN }}" |
jq -r '.mergeable'
}
until [ "$(check_merge)" = true -o "$(check_merge)" = false ]; do
echo -n 'waiting...'
sleep 10
done
if [ "$(check_merge)" = true ]; then
curl -X PUT "https://api.github.com/repos/omgnetwork/elixir-omg/pulls/${{ github.event.pull_request.number }}/merge" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.HOUSE_KEEPER_BOT_TOKEN }}" \
--data "{\"commit_title\": \"auto-merged ${{ github.event.pull_request.number }}\"}"
else
echo "PR unmerged"
fi
24 changes: 24 additions & 0 deletions .github/workflows/auto-pr-for-branch-syncing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Auto PR for syncing master to master-v2

on:
push:
branches: [master]

jobs:
auto-pr-for-branch-syncing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create Pull Request
run: |
set -o xtrace
readonly FROM_BRANCH="master"
readonly TO_BRANCH="master-v2"
readonly TITLE="sync: auto syncing from ${FROM_BRANCH} to ${TO_BRANCH}"
readonly BODY="Time to sync \`${TO_BRANCH}\` with updates from \`${FROM_BRANCH}\`!"
curl -X POST "https://api.github.com/repos/omgnetwork/elixir-omg/pulls" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.HOUSE_KEEPER_BOT_TOKEN }}" \
--data "{\"title\": \"${TITLE}\", \"head\": \"${FROM_BRANCH}\", \"base\": \"${TO_BRANCH}\", \"body\": \"${BODY}\"}"

0 comments on commit cbece84

Please sign in to comment.