From 49314759500286b24dda1b1a31d10cff02942ab6 Mon Sep 17 00:00:00 2001 From: Shivangi Shree Date: Wed, 12 Aug 2026 23:37:31 +0530 Subject: [PATCH] =?UTF-8?q?[ACS-10175]=20Add=20logic=20to=20send=20notific?= =?UTF-8?q?ation=20only=20if=20the=20user=20adds=20labe=E2=80=A6=20(#12141?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ACS-10175] Add logic to send notification only if the user adds label after creating pr * [ACS-10175] Update label detection logic * [ACS-10175] check if pr createdAt and label addedAt is different * [ACS-10175] Add logic to send notification on adding A/N BDU label * [ACS-10175] Add issues to permissions * Make time difference 15 seconds * [ACS-10175] Fix version * [ACS-10175] Add condition checking * [ACS-10175] CR fixes * [ACS-10175] Add full sha --- .github/workflows/notify-on-an-bdu-label.yml | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/notify-on-an-bdu-label.yml b/.github/workflows/notify-on-an-bdu-label.yml index 7a1586d94e..2248248c4e 100644 --- a/.github/workflows/notify-on-an-bdu-label.yml +++ b/.github/workflows/notify-on-an-bdu-label.yml @@ -7,6 +7,7 @@ on: permissions: pull-requests: read + issues: read jobs: notify-bdu: @@ -18,7 +19,40 @@ jobs: github.event.label.name == 'A/N BDU' && github.event.pull_request.state == 'open' steps: + - name: Check if label was added after PR creation (with time threshold) + id: check_label_timing + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 + with: + script: | + const prCreatedAt = new Date('${{ github.event.pull_request.created_at }}'); + + const timeline = await github.rest.issues.listEvents({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const labelEvent = timeline.data.reverse().find(event => + event.event === 'labeled' && + event.label.name === 'A/N BDU' + ); + + if (!labelEvent) { + core.setOutput('should_notify', 'false'); + return; + } + + const labelAddedAt = new Date(labelEvent.created_at); + const timeDiffSeconds = (labelAddedAt - prCreatedAt) / 1000; + + if (timeDiffSeconds > 15) { + core.setOutput('should_notify', 'true'); + } else { + core.setOutput('should_notify', 'false'); + } + - name: Send Teams notification + if: steps.check_label_timing.outputs.should_notify == 'true' uses: Alfresco/alfresco-build-tools/.github/actions/send-teams-notification@5177eca5d3d71342d7f7e0a2a4d74cc16b1eeb1b # v18.21.3 with: webhook-url: ${{ secrets.TEAMS_NOTIFICATION_ADF_BDU_WEBHOOK }}