Skip to content

Commit 0374acd

Browse files
Merge dev into v1.1-dev-sync-with-dev
2 parents 6084cd8 + 1953f32 commit 0374acd

3 files changed

Lines changed: 137 additions & 1 deletion

File tree

.github/workflows/schema-publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
id: generate-token
2727
uses: actions/create-github-app-token@v3
2828
with:
29-
app-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }}
29+
client-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }}
3030
private-key: ${{ secrets.OAI_SPEC_PUBLISHER_PRIVATE_KEY }}
3131
owner: OAI
3232
repositories: spec.openapis.org
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: sync-dev-to-vX.Y-dev
2+
3+
# author: @ralfhandl
4+
5+
#
6+
# This workflow creates PRs to update the vX.Y-dev branch with the latest changes from dev
7+
#
8+
9+
# run this on push to dev
10+
on:
11+
push:
12+
branches:
13+
- dev
14+
workflow_dispatch: {}
15+
16+
jobs:
17+
sync-branches:
18+
if: github.repository == 'OAI/Arazzo-Specification'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Generate access token
22+
id: generate-token
23+
uses: actions/create-github-app-token@v3
24+
with:
25+
client-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }}
26+
private-key: ${{ secrets.OAI_SPEC_PUBLISHER_PRIVATE_KEY }}
27+
28+
- name: Checkout repository
29+
uses: actions/checkout@v7
30+
with:
31+
fetch-depth: 0
32+
token: ${{ steps.generate-token.outputs.token }}
33+
34+
- name: Create pull requests
35+
id: pull_requests
36+
shell: bash
37+
run: |
38+
git config user.name "github-actions[bot]"
39+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
40+
41+
DEV_BRANCHES=$(git branch -r --list origin/v?.?-dev)
42+
for DEV_BRANCH in $DEV_BRANCHES; do
43+
BASE=${DEV_BRANCH:7}
44+
SYNC="$BASE-sync-with-$HEAD"
45+
46+
git checkout -b $SYNC origin/$SYNC || git checkout -b $SYNC origin/$BASE
47+
git merge origin/$HEAD -m "Merge $HEAD into $SYNC"
48+
git checkout origin/$BASE src/
49+
git checkout origin/$BASE tests/schema/
50+
git commit -m "Restored src/ and tests/schema/" || echo ""
51+
git push -u origin $SYNC
52+
53+
EXISTS=$(gh pr list --base $BASE --head $SYNC \
54+
--json number --jq '.[] | .number')
55+
if [ ! -z "$EXISTS" ]; then
56+
echo "PR #$EXISTS already wants to merge $SYNC into $BASE"
57+
continue
58+
fi
59+
60+
PR=$(gh pr create --base $BASE --head $SYNC \
61+
--label "Housekeeping" \
62+
--title "$BASE: sync with $HEAD" \
63+
--body "Merge relevant changes from \`$HEAD\` into \`$BASE\`.")
64+
echo ""
65+
echo "PR to sync $BASE with $HEAD: $PR"
66+
sleep 60 # allow status checks to be triggered
67+
68+
gh pr checks $PR --watch --required || continue
69+
gh pr merge $PR --merge --admin
70+
done
71+
env:
72+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
73+
HEAD: dev
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: sync-main-to-dev
2+
3+
# author: @ralfhandl
4+
5+
#
6+
# This workflow creates PRs to update the dev branch with the latest changes from main
7+
#
8+
9+
# run this on push to main
10+
on:
11+
push:
12+
branches:
13+
- main
14+
workflow_dispatch: {}
15+
16+
jobs:
17+
sync-branch:
18+
if: github.repository == 'OAI/Arazzo-Specification'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Generate access token
22+
id: generate-token
23+
uses: actions/create-github-app-token@v3
24+
with:
25+
client-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }}
26+
private-key: ${{ secrets.OAI_SPEC_PUBLISHER_PRIVATE_KEY }}
27+
28+
- name: Checkout repository
29+
uses: actions/checkout@v7
30+
with:
31+
fetch-depth: 0
32+
token: ${{ steps.generate-token.outputs.token }}
33+
34+
- name: Create pull request
35+
id: pull_request
36+
shell: bash
37+
run: |
38+
git config user.name "github-actions[bot]"
39+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
40+
SYNC="$BASE-sync-with-$HEAD"
41+
42+
git checkout -b $SYNC origin/$SYNC || git checkout -b $SYNC origin/$BASE
43+
git merge origin/$HEAD -m "Merge $HEAD into $SYNC"
44+
git checkout origin/$BASE src/
45+
git checkout origin/$BASE tests/schema/
46+
git commit -m "Restored src/ and tests/schema/" || echo ""
47+
git push -u origin $SYNC
48+
49+
EXISTS=$(gh pr list --base $BASE --head $SYNC \
50+
--json number --jq '.[] | .number')
51+
if [ ! -z "$EXISTS" ]; then
52+
echo "PR #$EXISTS already wants to merge $SYNC into $BASE"
53+
exit 0
54+
fi
55+
56+
gh pr create --base $BASE --head $SYNC \
57+
--label "Housekeeping" \
58+
--title "$BASE: sync with $HEAD" \
59+
--body "Merge relevant changes from \`$HEAD\` into \`$BASE\`."
60+
env:
61+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
62+
HEAD: main
63+
BASE: dev

0 commit comments

Comments
 (0)