diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml index b86bc02..4c380d9 100644 --- a/.github/workflows/post-merge.yml +++ b/.github/workflows/post-merge.yml @@ -29,16 +29,26 @@ jobs: export NEW_VERSION=$(date +%Y%m%d)-$REVISION_ID echo "Setting version to $NEW_VERSION" echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV - mvn versions:set -DnewVersion=$NEW_VERSION + mvn versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false mvn versions:commit + - name: Debug Git Changes + run: | + git status + git diff pom.xml + - name: Create new branch and commit changes run: | git config user.name "GitHub Actions Bot" git config user.email "actions@github.com" git checkout -b update-version-${{ env.NEW_VERSION }} git add pom.xml - git commit -m "Update project version to ${{ env.NEW_VERSION }}" + if git status --porcelain | grep .; then + git commit -m "Update project version to ${{ env.NEW_VERSION }}" + else + echo "No changes to commit. Exiting." + exit 0 + fi - name: Push changes to new branch run: | @@ -51,4 +61,12 @@ jobs: title: "Update project version to ${{ env.NEW_VERSION }}" body: "Automated version update by GitHub Actions." branch: update-version-${{ env.NEW_VERSION }} - base: main \ No newline at end of file + base: main + + - name: Enable Pull Request Automerge + if: steps.cpr.outputs.pull-request-number != '' + uses: peter-evans/enable-pull-request-automerge@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + merge-method: merge \ No newline at end of file