-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 8.1.x-deconflict
- Loading branch information
Showing
97 changed files
with
4,058 additions
and
3,554 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
name: Sync PR | ||
|
||
on: | ||
push: | ||
branches: | ||
- '8.*.x' | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: Branch to merge into master | ||
required: true | ||
|
||
jobs: | ||
sync: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
env: | ||
BRANCH: ${{ inputs.branch || github.ref_name }} | ||
steps: | ||
- name: Check branch name | ||
shell: python | ||
run: | | ||
import os | ||
import sys | ||
branch = os.environ['BRANCH'].strip() | ||
if not branch: | ||
sys.exit("::error::Branch name cannot be empty") | ||
if branch.endswith('deconflict'): | ||
sys.exit("::error::Do not run this workflow for already-created deconflict branches") | ||
with open(os.environ['GITHUB_ENV'], 'a') as F: | ||
print(f'BRANCH={branch}', file=F) | ||
print(f'DECONFLICT_BRANCH={branch}-deconflict', file=F) | ||
- name: Check for existing PR | ||
id: check-pr | ||
shell: python | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
import os | ||
import json | ||
import subprocess | ||
import sys | ||
for env_var in ('BRANCH', 'DECONFLICT_BRANCH'): | ||
branch = os.environ[env_var] | ||
cmd = f'gh pr list -B master -H {branch} -s open --json url -R ${{ github.repository }}' | ||
ret = subprocess.run( | ||
cmd, shell=True, capture_output=True, text=True | ||
) | ||
print(ret.stdout) | ||
if ret.stderr: | ||
print(f"::error::{ret.stderr}") | ||
if ret.returncode: | ||
sys.exit(ret.returncode) | ||
if json.loads(ret.stdout): | ||
print(f"::notice::Found existing PR for {branch}") | ||
sys.exit(0) | ||
print("No open PRs found") | ||
with open(os.environ['GITHUB_OUTPUT'], 'a') as f: | ||
print('continue=true', file=f) | ||
- name: Checkout | ||
if: steps.check-pr.outputs.continue | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: master | ||
|
||
- name: Configure git | ||
if: steps.check-pr.outputs.continue | ||
uses: cylc/release-actions/configure-git@v1 | ||
|
||
- name: Attempt merge | ||
id: merge | ||
if: steps.check-pr.outputs.continue | ||
continue-on-error: true | ||
run: git merge "origin/${BRANCH}" | ||
|
||
- name: Diff | ||
id: diff | ||
if: steps.merge.outcome == 'success' | ||
run: | | ||
if [[ "$(git rev-parse HEAD)" == "$(git rev-parse origin/master)" ]]; then | ||
echo "::notice::master is up to date with $BRANCH" | ||
exit 0 | ||
fi | ||
if git diff HEAD^ --exit-code --stat; then | ||
echo "::notice::No diff between master and $BRANCH" | ||
exit 0 | ||
fi | ||
echo "continue=true" >> $GITHUB_OUTPUT | ||
- name: Create deconflict branch | ||
if: steps.merge.outcome == 'failure' | ||
run: | | ||
git merge --abort | ||
git checkout -b "$DECONFLICT_BRANCH" "origin/${BRANCH}" | ||
git push origin "$DECONFLICT_BRANCH" | ||
echo "BRANCH=${DECONFLICT_BRANCH}" >> $GITHUB_ENV | ||
- name: Open PR | ||
if: steps.merge.outcome == 'failure' || steps.diff.outputs.continue | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh pr create --head "$BRANCH" \ | ||
--title "🤖 Merge ${BRANCH} into master" \ | ||
--body "Please do a **normal merge**, not squash merge\n\n---\n\nTriggered by ${GITHUB_EVENT_NAME}" | ||
gh pr edit "$BRANCH" --add-label "sync" || true |
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
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
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
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
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
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
Oops, something went wrong.