diff --git a/.github/workflows/tryout-sbt-version-policy.yml b/.github/workflows/tryout-sbt-version-policy.yml new file mode 100644 index 0000000..02c835e --- /dev/null +++ b/.github/workflows/tryout-sbt-version-policy.yml @@ -0,0 +1,18 @@ +name: Compatibility Report +on: + workflow_dispatch: + pull_request: + +jobs: + add_compatibility_report_to_pr: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Add Compatibility Report + run: ./update_pr_with_compatibility_info.sh "$PR_NUMBER" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.number }} diff --git a/update_pr_with_compatibility_info.sh b/update_pr_with_compatibility_info.sh new file mode 100755 index 0000000..53d832e --- /dev/null +++ b/update_pr_with_compatibility_info.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +pr_number=$1 + +required_label="Breaks Binary Compatibility" + +current_labels=$(gh pr view $pr_number --json labels --jq '.labels[].name | select(endswith("Compatibility"))') + +printf "PR %s Current labels:\n%s\n\n" "$pr_number" "$current_labels" + +current_labels_to_remove=$(grep -Fx --invert-match "$required_label" <(echo "$current_labels") | paste -sd ',' -) + +echo "current_labels_to_remove = $current_labels_to_remove" + +gh pr edit $pr_number --remove-label "$current_labels_to_remove" --add-label "$required_label" + +if grep -Fxq "$required_label" <(echo "$current_labels") ; then + echo "The '$required_label' label was already present, no need to comment" +else + echo "The '$required_label' label was not already present, PR has changed compatability level" + gh pr comment $pr_number --body "Mock info: This PR $required_label when compared against most recent release 3.0.0. Details..." +fi