add pipeline output for debugging #33
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: Builds-Mattermost | |
| on: | |
| workflow_call: | |
| secrets: | |
| WEBHOOK: | |
| required: true | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| notify: | |
| name: Mattermost | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: technote-space/workflow-conclusion-action@v3 | |
| - name: Create Mattermost Message | |
| env: | |
| REPOSITORY: ${{ github.repository }} | |
| REPOSITORY_URL: ${{ github.repository.html_url }} | |
| REF: ${{ github.ref_name }} | |
| ACTOR: ${{ github.actor }} | |
| TITLE: ${{ github.workflow }} | |
| BODY: ${{ toJSON(github.event.head_commit.message) }} | |
| ANSWER: ${{ github.event.issue.comments_url }} | |
| LINK: ${{ github.event.head_commit.url }} | |
| shell: bash | |
| run: | | |
| AUTHOR=${ACTOR} | |
| ICON=":octagonal_sign:" | |
| STATUS_TEXT="${{ env.WORKFLOW_CONCLUSION }}" | |
| if [ "${{ env.WORKFLOW_CONCLUSION }}" == "success" ]; then | |
| ICON=":robot:" | |
| fi | |
| if [ "${{ env.WORKFLOW_CONCLUSION }}" == "skipped" ]; then | |
| ICON=":person_doing_cartwheel:" | |
| fi | |
| # Properly handle JSON-escaped body - strip outer quotes and truncate | |
| BODYLINE='${{ toJSON(github.event.head_commit.message) }}' | |
| BODYLINE="${BODYLINE#\"}" | |
| BODYLINE="${BODYLINE%\"}" | |
| TRIMMED_BODY="${BODYLINE:0:350}" | |
| # Create JSON using jq for proper escaping | |
| jq -n \ | |
| --arg icon "$ICON" \ | |
| --arg ref "$REF" \ | |
| --arg status "$STATUS_TEXT" \ | |
| --arg repo "$REPOSITORY" \ | |
| --arg repo_url "$REPOSITORY_URL" \ | |
| --arg author "$AUTHOR" \ | |
| --arg body "$TRIMMED_BODY" \ | |
| --arg link "$LINK" \ | |
| '{text: ("## \($icon) \($ref)\nStatus: \($status)\nin: [\($repo)](\($repo_url)) by: **\($author)**\n\n```text\n\($body)\n```\n----\n[Commit](\($link))")}' \ | |
| > mattermost.json | |
| - name: Read Content | |
| id: getcontent | |
| run: echo "::set-output name=payload::$(cat mattermost.json)" | |
| - name: Pipeline Output | |
| run: echo "${{ steps.getcontent.outputs.payload }}" | |
| - name: Send Mattermost Message | |
| uses: mattermost/action-mattermost-notify@master | |
| with: | |
| MATTERMOST_WEBHOOK_URL: ${{ secrets.WEBHOOK }} | |
| PAYLOAD: |- | |
| ${{ steps.getcontent.outputs.payload }} |