diff --git a/.github/workflows/pr-check.yaml b/.github/workflows/pr-check.yaml index b1f71bab..8ecb83ca 100644 --- a/.github/workflows/pr-check.yaml +++ b/.github/workflows/pr-check.yaml @@ -12,9 +12,23 @@ on: jobs: prepr-check: runs-on: ubuntu-latest + permissions: + pull-requests: write steps: - name: checkout uses: actions/checkout@v3 + - uses: jwalton/gh-find-current-pr@v1 + id: PR + with: + state: open - name: pr-check run: | - docker run --rm -v $(pwd):/src -w /src -e SKIP_CHECKOV mcr.microsoft.com/azterraform:latest make pr-check + docker run --rm -v $(pwd):/src -w /src -e SKIP_CHECKOV mcr.microsoft.com/azterraform:latest make pr-check + - name: Breaking Change Brief + run: | + change=$(docker run --rm -t -v $(pwd):/src -w /src mcr.microsoft.com/azterraform:latest breaking_detect /src ${{ github.repository_owner }} ${{ github.event.repository.name }} ${{ github.base_ref }}) + if [ ! -z "$change" ]; then + msg=$(printf "Potential Breaking Changes in ${{ github.event.pull_request.head.sha }}:\n${change}") + jq -n --arg msg "$msg" '{body: $msg}' > body.txt + curl -s -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.PR.outputs.pr }}/comments -d @body.txt + fi \ No newline at end of file