forked from the-benchmarker/web-frameworks
-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (38 loc) · 1.22 KB
/
Copy pathsync-master-to-develop.yml
File metadata and controls
45 lines (38 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Sync master to develop
on:
pull_request_target:
branches: [master]
types: [closed]
permissions:
contents: read
pull-requests: write
concurrency:
group: sync-master-to-develop
cancel-in-progress: false
jobs:
sync:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Open sync PR if needed
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
existing_pr=$(gh pr list --base develop --head master --state open --json number --jq '.[0].number // empty')
if [[ -n "$existing_pr" ]]; then
echo "Sync PR #$existing_pr already exists."
exit 0
fi
ahead=$(gh api "repos/$GH_REPO/compare/develop...master" --jq '.ahead_by')
if [[ "$ahead" -eq 0 ]]; then
echo "develop already contains master."
exit 0
fi
gh pr create \
--base develop \
--head master \
--title "Sync master into develop" \
--body "Automatically sync changes merged into master back into develop. CI is skipped for this branch pair."