-
Notifications
You must be signed in to change notification settings - Fork 9.2k
73 lines (62 loc) · 2.35 KB
/
sync-dev-to-vX.Y-dev.yaml
File metadata and controls
73 lines (62 loc) · 2.35 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: sync-dev-to-vX.Y-dev
# author: @ralfhandl
#
# This workflow creates PRs to update the vX.Y-dev branch with the latest changes from dev
#
# run this on push to dev
on:
push:
branches:
- dev
workflow_dispatch: {}
jobs:
sync-branches:
if: github.repository == 'OAI/OpenAPI-Specification'
runs-on: ubuntu-latest
steps:
- name: Generate access token
id: generate-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }}
private-key: ${{ secrets.OAI_SPEC_PUBLISHER_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Create pull requests
id: pull_requests
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
DEV_BRANCHES=$(git branch -r --list origin/v?.?-dev)
for DEV_BRANCH in $DEV_BRANCHES; do
BASE=${DEV_BRANCH:7}
SYNC="$BASE-sync-with-$HEAD"
git checkout -b $SYNC origin/$SYNC || git checkout -b $SYNC origin/$BASE
git merge origin/$HEAD -m "Merge $HEAD into $SYNC"
git checkout origin/$BASE src/
git checkout origin/$BASE tests/schema/
git commit -m "Restored src/ and tests/schema/" || echo ""
git push -u origin $SYNC
EXISTS=$(gh pr list --base $BASE --head $SYNC \
--json number --jq '.[] | .number')
if [ ! -z "$EXISTS" ]; then
echo "PR #$EXISTS already wants to merge $SYNC into $BASE"
continue
fi
PR=$(gh pr create --base $BASE --head $SYNC \
--label "Housekeeping" \
--title "$BASE: sync with $HEAD" \
--body "Merge relevant changes from \`$HEAD\` into \`$BASE\`.")
echo ""
echo "PR to sync $BASE with $HEAD: $PR"
sleep 60 # allow status checks to be triggered
gh pr checks $PR --watch --required || continue
gh pr merge $PR --merge --admin
done
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
HEAD: dev