From 0769ea8f8469dd6a7dc46c0e8c8ce726ed0be25b Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Thu, 21 Mar 2024 19:44:07 +0100 Subject: [PATCH] attempt merging --- .../create-merge-release-into-dev-pr.yml | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/.github/workflows/create-merge-release-into-dev-pr.yml b/.github/workflows/create-merge-release-into-dev-pr.yml index d11a316ac767..68a461548003 100644 --- a/.github/workflows/create-merge-release-into-dev-pr.yml +++ b/.github/workflows/create-merge-release-into-dev-pr.yml @@ -2,6 +2,9 @@ name: create-merge-release-into-dev-pr on: workflow_dispatch: +env: + BASE_BRANCH: test-dev + permissions: {} jobs: setup: @@ -25,13 +28,49 @@ jobs: echo "branch=${BRANCH}" >> $GITHUB_OUTPUT - create-pr: + try-merging: permissions: - pull-requests: write # for git push + contents: write # for git push runs-on: ubuntu-latest needs: setup timeout-minutes: 5 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ env.BASE_BRANCH }} # TODO: DELETE ME + - name: Try merging + run: | + # Fetching the dev and release branches without fetching their complete history + # First fetch branches themselves excluding commits reachable by the other branch + git fetch --shallow-exclude "$BASE_BRANCH" origin "$RELEASE_BRANCH" + git fetch --shallow-exclude "$RELEASE_BRANCH" origin "$BASE_BRANCH" + # Resolve bug in git https://stackoverflow.com/a/63879454/96823 + git repack -d + # Get one commit more to connect the history of dev and release branches + git fetch --deepen 1 origin "$BASE_BRANCH" "$RELEASE_BRANCH" + + git branch "$RELEASE_BRANCH" origin/"$RELEASE_BRANCH" + + git config user.name "OpenProject Actions CI" + git config user.email "operations+ci@openproject.com" + + git diff ..."$RELEASE_BRANCH" + + git merge --no-edit --no-ff "$RELEASE_BRANCH" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_BRANCH: ${{ needs.setup.outputs.latest_release_branch }} + + create-pr: + permissions: + pull-requests: write # for creating pull request + + runs-on: ubuntu-latest + needs: [setup, try-merging] + timeout-minutes: 5 + if: false # TODO: DELETE ME steps: - name: Checkout repository uses: actions/checkout@v4 @@ -44,5 +83,4 @@ jobs: --body 'Created by GitHub action' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BASE_BRANCH: dev RELEASE_BRANCH: ${{ needs.setup.outputs.latest_release_branch }}