diff --git a/.github/workflows/promote-main-to-release-candidate.yml b/.github/workflows/promote-main-to-release-candidate.yml index 5e81e33..7d5b39e 100644 --- a/.github/workflows/promote-main-to-release-candidate.yml +++ b/.github/workflows/promote-main-to-release-candidate.yml @@ -3,6 +3,9 @@ name: Promote main to release candidate on: push: branches: [main] + pull_request_target: + types: [synchronize] + branches: [release-candidate] workflow_dispatch: permissions: @@ -16,7 +19,12 @@ concurrency: jobs: sync: - if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }} + if: >- + github.event_name == 'push' || + (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') || + (github.event_name == 'pull_request_target' && + github.event.pull_request.head.ref == 'automation/main-to-release-candidate' && + github.event.pull_request.head.repo.full_name == github.repository) runs-on: ubuntu-latest steps: - name: Create or reuse promotion pull request @@ -25,9 +33,21 @@ jobs: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} run: | + promotion_branch="automation/main-to-release-candidate" + main_sha="$(gh api "repos/${GITHUB_REPOSITORY}/git/ref/heads/main" --jq '.object.sha')" + if ! gh api --method POST "repos/${GITHUB_REPOSITORY}/git/refs" \ + -f "ref=refs/heads/${promotion_branch}" \ + -f "sha=${main_sha}"; then + if ! gh api --method PATCH "repos/${GITHUB_REPOSITORY}/git/refs/heads/${promotion_branch}" \ + -f "sha=${main_sha}" \ + -F force=false; then + echo "Promotion branch has diverged from main; leaving it unchanged for conflict resolution." + fi + fi + pr_number="$(gh pr list \ --base release-candidate \ - --head main \ + --head "$promotion_branch" \ --state open \ --json number \ --jq '.[0].number // empty')" @@ -35,9 +55,9 @@ jobs: if [[ -z "$pr_number" ]]; then pr_number="$(gh pr create \ --base release-candidate \ - --head main \ + --head "$promotion_branch" \ --title "Sync main into release-candidate" \ - --body $'Automated promotion of the latest main branch changes into release-candidate.\n\nThis pull request is maintained by the Promote main to release candidate workflow.')" + --body $'Automated promotion of the latest main branch changes into release-candidate.\n\nThis pull request is maintained by the Promote main to release candidate workflow. Its dedicated branch allows Copilot to resolve conflicts without modifying the default branch.')" fi echo "number=$pr_number" >> "$GITHUB_OUTPUT" @@ -79,9 +99,9 @@ jobs: --jq '.[].body' | grep -Fq "$marker"; then gh pr comment "$PR_NUMBER" --body "$(cat <<'EOF' - @copilot Please resolve the merge conflicts in this pull request between `main` and `release-candidate`. + @copilot Please resolve the merge conflicts in this pull request. The head branch contains the latest `main` changes and the base is `release-candidate`. - Preserve the intended changes from both branches, run the repository's relevant checks, and push the conflict resolution to this pull request's head branch. Do not merge the pull request yourself; leave it ready for this workflow to auto-merge once it is clean. + Preserve the intended changes from both branches, run the repository's relevant checks, and push the conflict resolution to this pull request's dedicated head branch. Do not merge the pull request yourself; leave it ready for this workflow to auto-merge once it is clean. EOF )" fi diff --git a/DynamicsActivitiesPackage/DynamicsActivitiesPackage/DynamicsActivitiesPackage.csproj b/DynamicsActivitiesPackage/DynamicsActivitiesPackage/DynamicsActivitiesPackage.csproj index 1b05613..8a50cf2 100644 --- a/DynamicsActivitiesPackage/DynamicsActivitiesPackage/DynamicsActivitiesPackage.csproj +++ b/DynamicsActivitiesPackage/DynamicsActivitiesPackage/DynamicsActivitiesPackage.csproj @@ -8,8 +8,8 @@ True 10.3.0.0 - 12752 - 1.8.90 - Refresh promotion workflow registration + 1.8.91 + Use a dedicated branch for promotion conflict resolution skyline:sdk:dataminertoken skyline:sdk:dataminertoken diff --git a/README.md b/README.md index e171685..0329a1f 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ and the frontend build base path is set to `/public/DynamicsActivitiesDev/` so s | `.github/workflows/deploy-dma-on-pr-merge.yml` | Caller workflow for production-on-merge, manual `production` from `main` only, and manual `dev` deploys | | `.github/workflows/deploy-dmapp-reusable.yml` | Reusable build/register/deploy workflow for DMAPP packaging and Catalog deployment | | `.github/workflows/copilot-bug-triage.yml` | Auto-comments on `bug`-labeled issues to ask `@copilot` for investigation | -| `.github/workflows/promote-main-to-release-candidate.yml` | Opens or updates the `main` → `release-candidate` promotion PR after changes reach `main`, enables auto-merge, and asks `@copilot` to resolve conflicts | +| `.github/workflows/promote-main-to-release-candidate.yml` | Opens or updates the `main` → `release-candidate` promotion PR after changes reach `main`, using a dedicated branch so `@copilot` can resolve conflicts without modifying `main` | ### Release candidate deployment