Skip to content

Commit

Permalink
Automatically create merge PRs for feature/9.x (#6073)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmittjoseph committed Feb 26, 2024
1 parent 4e0d81f commit ab8be51
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
11 changes: 9 additions & 2 deletions .github/actions/open-pr/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ inputs:
fail_if_files_unchanged:
description: 'Fails the action if all of the specified files_to_commit are unchanged.'
required: false
always_create_pr:
description: 'Always try to create a PR, even if there are no uncommitted changes.'
required: false
update_if_already_exists:
description: 'Allows updating an existing PR, or re-opening it if closed.'
required: false
Expand Down Expand Up @@ -61,10 +64,13 @@ runs:
exit 1
fi
exit 0
if [[ "$ALWAYS_CREATE_PR" != "true" ]]; then
exit 0
fi
else
git commit -m "$COMMIT_MESSAGE"
fi
git commit -m "$COMMIT_MESSAGE"
git push --force --set-upstream origin "HEAD:$pr_branch_name"
extraArgs=""
Expand All @@ -81,6 +87,7 @@ runs:
COMMIT_MESSAGE: ${{ inputs.commit_message }}
DRAFT: ${{ inputs.draft }}
LABELS: ${{ inputs.labels }}
ALWAYS_CREATE_PR: ${{ inputs.always_create_pr }}
FAIL_IF_FILES_UNCHANGED: ${{ inputs.fail_if_files_unchanged }}
UPDATE_IF_ALREADY_EXISTS: ${{ inputs.update_if_already_exists }}
TITLE: ${{ inputs.title }}
Expand Down
53 changes: 50 additions & 3 deletions .github/workflows/sync-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ env:
base_branch: 'origin/main'

jobs:
sync-branch:
sync-non-code:
if: github.repository == 'dotnet/dotnet-monitor'
strategy:
matrix:
branch: ["release/6.x", "release/7.x", "release/8.0"]
name: 'Sync ${{ matrix.branch }}'
name: 'Sync non-code to ${{ matrix.branch }}'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -39,14 +39,61 @@ jobs:
"cspell.json" \
"documentation/**.md"
- name: Open PR
uses: ./.github/actions/open-pr
with:
files_to_commit: "*"
title: '[${{ matrix.branch }}] Sync non-code with ${{ env.base_branch }}'
commit_message: sync non-code with ${{ env.base_branch }}
body: Sync non-code with ${{ env.base_branch }}. This PR was auto generated and will not be automatically merged in.
branch_name: sync/${{ matrix.branch }}
fail_if_files_unchanged: false
labels: 'automatic-pr'
auth_token: ${{ secrets.GITHUB_TOKEN }}

sync-code:
if: github.repository == 'dotnet/dotnet-monitor'
strategy:
matrix:
branch: ["feature/9.x"]
name: 'Sync branch with ${{ matrix.branch }}'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
persist-credentials: true # We need to persist credentials to push the resulting changes upstream.
fetch-depth: 0 # Fetch the entire repo for the below git operations
ref: ${{ matrix.branch }}

- name: Sync branch
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git merge "$base_branch" --strategy=ort --strategy-option=theirs
git checkout "origin/${{ matrix.branch }}" -- \
"global.json" \
"eng/branch-vscode-config" \
"eng/common" \
"eng/Common.props" \
"eng/Versions.props" \
"eng/Version.Details.xml"
- name: Open PR
uses: ./.github/actions/open-pr
with:
files_to_commit: "*"
title: '[${{ matrix.branch }}] Sync branch with ${{ env.base_branch }}'
commit_message: sync branch with ${{ env.base_branch }}
commit_message: Resolve merge conflicts
body: Sync branch with ${{ env.base_branch }}. This PR was auto generated and will not be automatically merged in.
branch_name: sync/${{ matrix.branch }}
fail_if_files_unchanged: false
always_create_pr: true
labels: 'automatic-pr'
auth_token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit ab8be51

Please sign in to comment.