Changeset 51934
- Timestamp:
- 10/25/2021 07:28:04 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.github/workflows/slack-notifications.yml
r51924 r51934 7 7 8 8 on: 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 9 25 workflow_call: 10 26 secrets: … … 22 38 required: true 23 39 40 env: 41 CURRENT_BRANCH: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }} 42 24 43 jobs: 25 44 # Gathers the details needed for Slack notifications. … … 29 48 # 30 49 # Performs the following steps: 50 # - Retrieves the workflow ID (if necessary). 51 # - Retrieves the workflow URL (if necessary). 31 52 # - Retrieves the previous workflow run and stores its conclusion. 32 53 # - Sets the previous conclusion as an output. 54 # - Prepares the commit message. 33 55 # - Constructs and stores a message payload as an output. 34 56 prepare: … … 43 65 - name: Get the workflow ID 44 66 id: current-workflow-id 67 if: ${{ github.event_name == 'push' }} 45 68 uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0 46 69 with: … … 56 79 id: current-workflow-url 57 80 uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0 81 if: ${{ github.event_name == 'push' }} 58 82 with: 59 83 script: | … … 73 97 owner: '${{ github.repository_owner }}', 74 98 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 }}', 77 101 per_page: 1, 78 102 page: 2, … … 88 112 run: | 89 113 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 }} 91 115 EOF 92 116 ) … … 95 119 - name: Construct payload and store as an output 96 120 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 }}\"}" 98 122 99 123 # Posts notifications when a workflow fails. … … 102 126 runs-on: ubuntu-latest 103 127 needs: [ prepare ] 104 if: ${{ failure()}}128 if: ${{ github.event_name == 'push' && failure() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' }} 105 129 106 130 steps: … … 117 141 runs-on: ubuntu-latest 118 142 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' ) }} 120 144 121 145 steps: … … 132 156 runs-on: ubuntu-latest 133 157 needs: [ prepare ] 134 if: ${{ success()}}158 if: ${{ github.event_name == 'push' && success() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }} 135 159 136 160 steps: … … 147 171 runs-on: ubuntu-latest 148 172 needs: [ prepare ] 149 if: ${{ cancelled()}}173 if: ${{ github.event_name == 'push' && cancelled() || github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'cancelled' }} 150 174 151 175 steps:
Note: See TracChangeset
for help on using the changeset viewer.