Abstract PR scrub action so it can be used in two places (#39329)
* Abstract PR scrub action so it can be used in two places * Rename composite action; add newline
This commit is contained in:
parent
147db933be
commit
bfedd049c1
|
@ -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: |
|
||||||
|
<!subteam^${{ inputs.WOO_PR_TESTING_ANALYSIS_TEAM_ID }}>, 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:* <!date^${{ steps.calculate_sla.outputs.sla_timestamp }}^{date_short_pretty} at {time}|5 hours from now>
|
||||||
|
slack-optional-unfurl_links: false
|
||||||
|
slack-optional-unfurl_media: false
|
|
@ -51,3 +51,17 @@ jobs:
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
labels: 'needs: analysis'
|
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 }}
|
||||||
|
|
|
@ -10,25 +10,15 @@ jobs:
|
||||||
if: "${{ github.event.label.name == 'needs: analysis' && (github.event.pull_request.state == 'open' || github.event.pull_request.merged) }}"
|
if: "${{ github.event.label.name == 'needs: analysis' && (github.event.pull_request.state == 'open' || github.event.pull_request.merged) }}"
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: Get the PR status
|
- uses: actions/checkout@v3
|
||||||
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
|
|
||||||
with:
|
with:
|
||||||
slack-bot-user-oauth-access-token: ${{ secrets.TEST_ASSISTANCE_BOT_TOKEN }}
|
sparse-checkout: |
|
||||||
slack-channel: ${{ secrets.WOO_PR_TESTING_ANALYSIS_SLACK_CHANNEL }}
|
.github/actions/pr-scrub-notify-slack
|
||||||
slack-text: |
|
ref: trunk
|
||||||
<!subteam^${{ secrets.WOO_PR_TESTING_ANALYSIS_TEAM_ID }}>, there is a new *${{ steps.get_pr_status.outputs.pr_status }}* PR to analyze.
|
- name: 'Trigger PR scrub'
|
||||||
<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> :thread:
|
uses: ./.github/actions/pr-scrub-notify-slack
|
||||||
*SLA:* <!date^${{ steps.calculate_sla.outputs.sla_timestamp }}^{date_short_pretty} at {time}|5 hours from now>
|
with:
|
||||||
slack-optional-unfurl_links: false
|
TEST_ASSISTANCE_BOT_TOKEN: ${{ secrets.TEST_ASSISTANCE_BOT_TOKEN }}
|
||||||
slack-optional-unfurl_media: false
|
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 }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue