diff --git a/.github/actions/pr-scrub-notify-slack/action.yml b/.github/actions/pr-scrub-notify-slack/action.yml new file mode 100644 index 00000000000..718ed72e6d7 --- /dev/null +++ b/.github/actions/pr-scrub-notify-slack/action.yml @@ -0,0 +1,38 @@ +name: Send PRs that require further testing to Slack +permissions: {} + +inputs: + TEST_ASSISTANCE_BOT_TOKEN: + default: '' + WOO_PR_TESTING_ANALYSIS_SLACK_CHANNEL: + default: '' + WOO_PR_TESTING_ANALYSIS_TEAM_ID: + default: '' + +runs: + using: composite + steps: + - name: Get the PR status + id: get_pr_status + shell: bash + run: | + pr_status=${{ github.event.pull_request.merged == true && 'merged' || 'open' }} + echo "pr_status=$pr_status" >> $GITHUB_OUTPUT + - name: Calculate SLA timestamp + id: calculate_sla + shell: bash + run: | + sla_timestamp=$(date -d "+ 5 hours" -u +%s) + echo "sla_timestamp=$sla_timestamp" >> $GITHUB_OUTPUT + - name: Notify Slack + uses: archive/github-actions-slack@d9dae40827adf93bddf939db6552d1e392259d7d + id: notify + with: + slack-bot-user-oauth-access-token: ${{ inputs.TEST_ASSISTANCE_BOT_TOKEN }} + slack-channel: ${{ inputs.WOO_PR_TESTING_ANALYSIS_SLACK_CHANNEL }} + slack-text: | + , there is a new *${{ steps.get_pr_status.outputs.pr_status }}* PR to analyze. + <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> :thread: + *SLA:* + slack-optional-unfurl_links: false + slack-optional-unfurl_media: false diff --git a/.github/workflows/pull-request-post-merge-processing.yml b/.github/workflows/pull-request-post-merge-processing.yml index 4d47340f4cb..5f3f6c80e06 100644 --- a/.github/workflows/pull-request-post-merge-processing.yml +++ b/.github/workflows/pull-request-post-merge-processing.yml @@ -51,3 +51,17 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} labels: 'needs: analysis' + - uses: actions/checkout@v3 + with: + sparse-checkout: | + .github/actions/pr-scrub-notify-slack + ref: trunk + - name: 'Trigger PR scrub' + if: | + github.event.pull_request.base.ref == 'trunk' && + ! contains(github.event.pull_request.labels.*.name, 'needs: analysis') + uses: ./.github/actions/pr-scrub-notify-slack + with: + TEST_ASSISTANCE_BOT_TOKEN: ${{ secrets.TEST_ASSISTANCE_BOT_TOKEN }} + WOO_PR_TESTING_ANALYSIS_SLACK_CHANNEL: ${{ secrets.WOO_PR_TESTING_ANALYSIS_SLACK_CHANNEL }} + WOO_PR_TESTING_ANALYSIS_TEAM_ID: ${{ secrets.WOO_PR_TESTING_ANALYSIS_TEAM_ID }} diff --git a/.github/workflows/test-assistant-pr-scrub.yml b/.github/workflows/test-assistant-pr-scrub.yml index 2611c7e50c5..1707072f4a3 100644 --- a/.github/workflows/test-assistant-pr-scrub.yml +++ b/.github/workflows/test-assistant-pr-scrub.yml @@ -10,25 +10,15 @@ jobs: if: "${{ github.event.label.name == 'needs: analysis' && (github.event.pull_request.state == 'open' || github.event.pull_request.merged) }}" runs-on: ubuntu-20.04 steps: - - name: Get the PR status - id: get_pr_status - run: | - pr_status=${{ github.event.pull_request.merged == true && 'merged' || 'open' }} - echo "pr_status=$pr_status" >> $GITHUB_OUTPUT - - name: Calculate SLA timestamp - id: calculate_sla - run: | - sla_timestamp=$(date -d "+ 5 hours" -u +%s) - echo "sla_timestamp=$sla_timestamp" >> $GITHUB_OUTPUT - - name: Notify Slack - uses: archive/github-actions-slack@d9dae40827adf93bddf939db6552d1e392259d7d - id: notify + - uses: actions/checkout@v3 with: - slack-bot-user-oauth-access-token: ${{ secrets.TEST_ASSISTANCE_BOT_TOKEN }} - slack-channel: ${{ secrets.WOO_PR_TESTING_ANALYSIS_SLACK_CHANNEL }} - slack-text: | - , there is a new *${{ steps.get_pr_status.outputs.pr_status }}* PR to analyze. - <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> :thread: - *SLA:* - slack-optional-unfurl_links: false - slack-optional-unfurl_media: false + sparse-checkout: | + .github/actions/pr-scrub-notify-slack + ref: trunk + - name: 'Trigger PR scrub' + uses: ./.github/actions/pr-scrub-notify-slack + with: + TEST_ASSISTANCE_BOT_TOKEN: ${{ secrets.TEST_ASSISTANCE_BOT_TOKEN }} + WOO_PR_TESTING_ANALYSIS_SLACK_CHANNEL: ${{ secrets.WOO_PR_TESTING_ANALYSIS_SLACK_CHANNEL }} + WOO_PR_TESTING_ANALYSIS_TEAM_ID: ${{ secrets.WOO_PR_TESTING_ANALYSIS_TEAM_ID }} +