Changeset 51953 for trunk/.github/workflows/slack-notifications.yml
- Timestamp:
- 10/29/2021 07:59:05 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.github/workflows/slack-notifications.yml
r51952 r51953 65 65 - name: Get the workflow ID 66 66 id: current-workflow-id 67 if: ${{ github.event_name == 'push' }}67 if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} 68 68 uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0 69 69 with: 70 70 script: | 71 71 const workflow_run = await github.rest.actions.getWorkflowRun({ 72 owner: '${{ github.repository_owner }}',73 repo: 'wordpress-develop',72 owner: context.repo.owner, 73 repo: context.repo.repo, 74 74 run_id: ${{ github.run_id }}, 75 75 }); 76 76 return workflow_run.data.workflow_id; 77 78 - name: Get the workflow URL79 id: current-workflow-url80 uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.081 if: ${{ github.event_name == 'push' }}82 with:83 script: |84 const workflow_run = await github.rest.actions.getWorkflowRun({85 owner: '${{ github.repository_owner }}',86 repo: 'wordpress-develop',87 run_id: ${{ github.run_id }},88 });89 return workflow_run.data.html_url;90 77 91 78 - name: Get details about the previous workflow run … … 95 82 script: | 96 83 const previous_runs = await github.rest.actions.listWorkflowRuns({ 97 owner: '${{ github.repository_owner }}',98 repo: 'wordpress-develop',84 owner: context.repo.owner, 85 repo: context.repo.repo, 99 86 workflow_id: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.workflow_id || steps.current-workflow-id.outputs.result }}, 100 87 branch: '${{ env.CURRENT_BRANCH }}', … … 108 95 run: echo "::set-output name=previous_conclusion::${{ steps.previous-result.outputs.result }}" 109 96 97 - name: Get the commit message 98 id: current-commit-message 99 uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0 100 if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }} 101 with: 102 script: | 103 const commit_details = await github.rest.repos.getCommit({ 104 owner: context.repo.owner, 105 repo: context.repo.repo, 106 ref: '${{ github.sha }}' 107 }); 108 return commit_details.data.commit.message; 109 110 110 - name: Prepare commit message. 111 111 id: commit-message 112 112 run: | 113 COMMIT_MESSAGE=$(cat <<'EOF' | awk 'NR==1' | sed 's/`/\\`/g' | sed 's/\"/\\\\ "/g' | sed 's/\$/\\$/g'114 ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_commit.message || github.event.head_commit.message }}113 COMMIT_MESSAGE=$(cat <<'EOF' | awk 'NR==1' | sed 's/`/\\`/g' | sed 's/\"/\\\\\\"/g' | sed 's/\$/\\$/g' 114 ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_commit.message || ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && fromJson( steps.current-commit-message.outputs.result ) || github.event.head_commit.message }} 115 115 EOF 116 116 ) … … 119 119 - name: Construct payload and store as an output 120 120 id: create-payload 121 run: echo "::set-output name=payload::{\"workflow_name\":\"${{ github.event_name == 'workflow_run' && github.event.workflow_run.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 }}\"}"121 run: echo "::set-output name=payload::{\"workflow_name\":\"${{ github.event_name == 'workflow_run' && github.event.workflow_run.name || github.workflow }}\",\"ref_name\":\"${{ env.CURRENT_BRANCH }}\",\"run_url\":\"https://github.com/WordPress/wordpress-develop/runs/${{ github.event_name == 'workflow_run' && github.event.workflow_run.id || github.run_id }}\",\"commit_message\":\"${{ steps.commit-message.outputs.commit_message_escaped }}\"}" 122 122 123 123 # Posts notifications when a workflow fails.
Note: See TracChangeset
for help on using the changeset viewer.