Delete close-source components. #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Notify Slack on Push | |
| on: | |
| push: | |
| branches: ['**'] | |
| jobs: | |
| slack_notify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Build the plain-text body and expose it as multiline output | |
| - name: Build Slack text | |
| id: build | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| REPO_URL="https://github.com/${{ github.repository }}" | |
| COMPARE_URL="${{ github.event.compare }}" | |
| text="*New push to branch \`${{ github.ref_name }}\` by \`${{ github.actor }}\`*" | |
| while IFS= read -r c; do | |
| sha=$(jq -r '.id' <<<"$c") | |
| msg=$(jq -r '.message' <<<"$c" | tr '\n' ' ') | |
| text+=$'\n' | |
| text+="• <${REPO_URL}/commit/${sha}|${sha:0:7}>: ${msg}" | |
| done < <(jq -c '.commits[]' "$GITHUB_EVENT_PATH") | |
| text+=$'\n\n' | |
| text+="🔗 *<${COMPARE_URL}|View all changes>*" | |
| # Multiline output (<<EOF syntax) | |
| { | |
| echo "text<<EOF" | |
| printf '%s\n' "$text" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| # 2. Post to Slack – the action serialises this object once | |
| - name: Send Slack notification | |
| uses: slackapi/slack-github-action@v1.24.0 | |
| with: | |
| payload: | | |
| { | |
| "text": ${{ toJson(steps.build.outputs.text) }} | |
| } | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |