diff --git a/.github/workflows/notify-pr-closed.yaml b/.github/workflows/notify-pr-closed.yaml new file mode 100644 index 0000000..8b918c3 --- /dev/null +++ b/.github/workflows/notify-pr-closed.yaml @@ -0,0 +1,41 @@ +name: Notify Teams on PR + +on: + pull_request: + types: [closed] + +jobs: + notify-teams: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Compute added/removed lines for notification + id: diff + run: | + PR_DATA=$(gh pr view "${{ github.event.pull_request.number }}" --json additions,deletions -q '.') + ADDITIONS=$(echo "$PR_DATA" | jq '.additions') + DELETIONS=$(echo "$PR_DATA" | jq '.deletions') + echo "additions=$ADDITIONS" >> $GITHUB_OUTPUT + echo "deletions=$DELETIONS" >> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Notify Microsoft Teams + uses: softwareone-platform/notify-pr-teams-action@v4 + with: + webhook_url: ${{ secrets.TEAMS_WEBHOOK_URL }} + bot_image_url: https://raw.githubusercontent.com/softwareone-platform/requela/main/.github/workflows/assets/turing_team_pr_bot.png + repo: ${{ github.repository }} + pr_url: ${{ github.event.pull_request.html_url }} + pr_title: ${{ github.event.pull_request.title }} + pr_author: ${{ github.event.pull_request.user.login }} + head_ref: ${{ github.event.pull_request.head.ref }} + base_ref: ${{ github.event.pull_request.base.ref }} + commits: ${{ github.event.pull_request.commits }} + changed_files: ${{ github.event.pull_request.changed_files }} + additions: ${{ steps.diff.outputs.additions }} + deletions: ${{ steps.diff.outputs.deletions }} + pr_number: ${{ github.event.pull_request.number }} + pr_status: ${{ github.event.pull_request.state }} + is_merged: ${{ github.event.pull_request.merged }} diff --git a/.github/workflows/pr-build-merge.yaml b/.github/workflows/pr-build-merge.yaml index dd810de..bd3fbdd 100644 --- a/.github/workflows/pr-build-merge.yaml +++ b/.github/workflows/pr-build-merge.yaml @@ -42,6 +42,37 @@ jobs: - name: Run tests run: uv run pytest + - name: Compute added/removed lines for notification + if: ${{ github.event_name == 'pull_request' }} + id: diff + run: | + PR_DATA=$(gh pr view "${{ github.event.pull_request.number }}" --json additions,deletions -q '.') + ADDITIONS=$(echo "$PR_DATA" | jq '.additions') + DELETIONS=$(echo "$PR_DATA" | jq '.deletions') + echo "additions=$ADDITIONS" >> $GITHUB_OUTPUT + echo "deletions=$DELETIONS" >> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Notify Microsoft Teams + if: ${{ github.event_name == 'pull_request' }} + uses: softwareone-platform/notify-pr-teams-action@v4 + with: + webhook_url: ${{ secrets.TEAMS_WEBHOOK_URL }} + bot_image_url: https://raw.githubusercontent.com/softwareone-platform/requela/main/.github/workflows/assets/turing_team_pr_bot.png + repo: ${{ github.repository }} + pr_url: ${{ github.event.pull_request.html_url }} + pr_title: ${{ github.event.pull_request.title }} + pr_author: ${{ github.event.pull_request.user.login }} + head_ref: ${{ github.event.pull_request.head.ref }} + base_ref: ${{ github.event.pull_request.base.ref }} + commits: ${{ github.event.pull_request.commits }} + changed_files: ${{ github.event.pull_request.changed_files }} + additions: ${{ steps.diff.outputs.additions }} + deletions: ${{ steps.diff.outputs.deletions }} + pr_number: ${{ github.event.pull_request.number }} + pr_status: ${{ github.event.pull_request.state }} + is_merged: ${{ github.event.pull_request.merged }} + - name: SonarQube Scan uses: sonarsource/sonarqube-scan-action@v4 env: