diff --git a/.github/workflows/pr_from_upstream.yml b/.github/workflows/pr_from_upstream.yml index c396d22..a68b9de 100644 --- a/.github/workflows/pr_from_upstream.yml +++ b/.github/workflows/pr_from_upstream.yml @@ -54,19 +54,26 @@ jobs: git merge --strategy-option theirs --no-edit FETCH_HEAD } - - name: Push changes if there are updates + - name: Create a new branch for PR if changes detected + id: create_branch env: BRANCH_NAME: "sync-${{ github.run_id }}" # Temporary branch name for the PR run: | if [ "$(git status --porcelain)" ]; then git checkout -b "$BRANCH_NAME" - git push origin "$BRANCH_NAME" + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV else - echo "No changes to push." + echo "No changes detected. Exiting." + exit 0 fi + - name: Push changes to new branch + if: success() + run: | + git push origin "$BRANCH_NAME" + - name: Create Pull Request - if: success() && steps.push.outputs.branch != '' # Only run if there are changes + if: success() uses: peter-evans/create-pull-request@v4 with: token: ${{ steps.generate-rekku-token.outputs.token || secrets.GITHUB_TOKEN }} @@ -112,4 +119,4 @@ jobs: ```bash git push origin ${{ env.BRANCH_NAME }} ``` - base: $TARGET_BRANCH + base: $TARGET_BRANCH \ No newline at end of file