diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe19702948..9fae8cb658 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,8 @@ on: push: branches: - "**" + pull_request: + types: [opened, synchronize, reopened] jobs: python-lint: @@ -38,7 +40,7 @@ jobs: strategy: max-parallel: 9 matrix: - os: [ windows-latest, ubuntu-20.04 ] + os: [windows-latest, ubuntu-20.04] steps: - name: Checkout github repo (+ download lfs dependencies) @@ -69,7 +71,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-20.04 ] + os: [ubuntu-20.04] steps: - name: Checkout github repo uses: actions/checkout@v3 @@ -92,7 +94,7 @@ jobs: sonarcloud: runs-on: ubuntu-20.04 - needs: [ python-test, npm-test ] + needs: [python-test, npm-test] steps: - uses: actions/checkout@v3 - name: Download python coverage report @@ -104,3 +106,29 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + auto-merge-or-squash: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Determine Merge Method + id: merge-method + run: | + commit_count=$(git rev-list --count HEAD ^$GITHUB_BASE_REF) + echo "Commit Count: $commit_count" + + if [ "$commit_count" -eq "1" ]; then + echo "::set-output name=METHOD::squash" + else + echo "::set-output name=METHOD::merge" + fi + + - name: Apply Merge Method + run: | + echo "Merge Method: ${{ steps.merge-method.outputs.METHOD }}" + gh pr merge ${{ github.event.pull_request.number }} --merge-method ${{ steps.merge-method.outputs.METHOD }} --repo $GITHUB_REPOSITORY + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr-management.yml b/.github/workflows/pr-management.yml new file mode 100644 index 0000000000..f03ed6708b --- /dev/null +++ b/.github/workflows/pr-management.yml @@ -0,0 +1,32 @@ +name: PR Management + +on: + pull_request: + branches: [test-actions] # TODO only for tests to be removed + types: [opened, synchronize, reopened] + +jobs: + auto-merge-or-squash: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Determine Merge Method + id: merge-method + run: | + commit_count=$(git rev-list --count HEAD ^$GITHUB_BASE_REF) + echo "Commit Count: $commit_count" + + if [ "$commit_count" -eq "1" ]; then + echo "::set-output name=METHOD::squash" + else + echo "::set-output name=METHOD::merge" + fi + + - name: Apply Merge Method + run: | + echo "Merge Method: ${{ steps.merge-method.outputs.METHOD }}" + gh pr merge ${{ github.event.pull_request.number }} --merge-method ${{ steps.merge-method.outputs.METHOD }} --repo $GITHUB_REPOSITORY + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}