Make WordPress Core


Ignore:
Timestamp:
10/25/2021 07:28:04 PM (3 years ago)
Author:
desrosj
Message:

Build/Test Tools: Restore Slack notifications for older branches.

In [51921], the GitHub Actions workflows were updated to utilize the Slack notifications workflow as a callable one instead of on the workflow_run event.

This eliminated the need for an additional “Slack Notifications” workflow run for every completed workflow, but only when other workflows are updated as well. This resulted in notifications from older branches breaking, as the changes in [51921] were not backported.

Instead of backporting the needed changes now (the Slack workflow is still being polished), this commit partially restores the workflow_run event for older branches so that notifications will resume.

See #53363.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/slack-notifications.yml

    r51924 r51934  
    77
    88on:
     9  workflow_run:
     10    workflows:
     11      - Code Coverage Report
     12      - Coding Standards
     13      - End-to-end Tests
     14      - JavaScript Tests
     15      - PHP Compatibility
     16      - PHPUnit Tests
     17      - Test NPM
     18      - Test old branches
     19    types:
     20      - completed
     21    branches:
     22      - '[3-4].[0-9]'
     23      - '5.[0-8]'
     24
    925  workflow_call:
    1026    secrets:
     
    2238        required: true
    2339
     40env:
     41  CURRENT_BRANCH: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }}
     42
    2443jobs:
    2544  # Gathers the details needed for Slack notifications.
     
    2948  #
    3049  # Performs the following steps:
     50  # - Retrieves the workflow ID (if necessary).
     51  # - Retrieves the workflow URL (if necessary).
    3152  # - Retrieves the previous workflow run and stores its conclusion.
    3253  # - Sets the previous conclusion as an output.
     54  # - Prepares the commit message.
    3355  # - Constructs and stores a message payload as an output.
    3456  prepare:
     
    4365      - name: Get the workflow ID
    4466        id: current-workflow-id
     67        if: ${{ github.event_name == 'push' }}
    4568        uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0
    4669        with:
     
    5679        id: current-workflow-url
    5780        uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0
     81        if: ${{ github.event_name == 'push' }}
    5882        with:
    5983          script: |
     
    7397              owner: '${{ github.repository_owner }}',
    7498              repo: 'wordpress-develop',
    75               workflow_id: ${{ steps.current-workflow-id.outputs.result }},
    76               branch: '${{ github.ref_name }}',
     99              workflow_id: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.workflow_id || steps.current-workflow-id.outputs.result }},
     100              branch: '${{ env.CURRENT_BRANCH }}',
    77101              per_page: 1,
    78102              page: 2,
     
    88112        run: |
    89113          COMMIT_MESSAGE=$(cat <<'EOF' | awk 'NR==1' | sed 's/`/\\`/g' | sed 's/\"/\\\\"/g'
    90           ${{ github.event.head_commit.message }}
     114          ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_commit.message || github.event.head_commit.message }}
    91115          EOF
    92116          )
     
    95119      - name: Construct payload and store as an output
    96120        id: create-payload
    97         run: echo "::set-output name=payload::{\"workflow_name\":\"${{ github.workflow }}\",\"ref_name\":\"${{ github.ref_name }}\",\"run_url\":\"${{ steps.current-workflow-url.outputs.result }}\",\"commit_message\":\"${{ steps.commit-message.outputs.commit_message_escaped }}\"}"
     121        run: echo "::set-output name=payload::{\"workflow_name\":\"${{ github.workflow }}\",\"ref_name\":\"${{ env.CURRENT_BRANCH }}\",\"run_url\":\"${{ github.event_name == 'workflow_run' && github.event.workflow_run.html_url || steps.current-workflow-url.outputs.result }}\",\"commit_message\":\"${{ steps.commit-message.outputs.commit_message_escaped }}\"}"
    98122
    99123  # Posts notifications when a workflow fails.
     
    102126    runs-on: ubuntu-latest
    103127    needs: [ prepare ]
    104     if: ${{ failure() }}
     128    if: ${{ github.event_name == 'push' && failure() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' }}
    105129
    106130    steps:
     
    117141    runs-on: ubuntu-latest
    118142    needs: [ prepare ]
    119     if: ${{ needs.prepare.outputs.previous_conclusion == 'failure' && success() }}
     143    if: ${{ needs.prepare.outputs.previous_conclusion == 'failure' && ( github.event_name == 'push' && success() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' ) }}
    120144
    121145    steps:
     
    132156    runs-on: ubuntu-latest
    133157    needs: [ prepare ]
    134     if: ${{ success() }}
     158    if: ${{ github.event_name == 'push' && success() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
    135159
    136160    steps:
     
    147171    runs-on: ubuntu-latest
    148172    needs: [ prepare ]
    149     if: ${{ cancelled() }}
     173    if: ${{ github.event_name == 'push' && cancelled() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'cancelled' }}
    150174
    151175    steps:
Note: See TracChangeset for help on using the changeset viewer.