diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 46833a112a..261d2f38b1 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -32,9 +32,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Post to Slack + env: + STATUS: ${{ inputs.status }} + ACTOR: ${{ inputs.actor }} + REPOSITORY: ${{ inputs.repository }} + BRANCH: ${{ inputs.branch }} + RUN_ID: ${{ inputs.run_id }} + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} run: | - if [ "${{ inputs.status }}" == "success" ]; then - payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" '{ + if [ "$STATUS" = "success" ]; then + payload=$(jq -n --arg repository "$REPOSITORY" --arg branch "$BRANCH" --arg actor "$ACTOR" --arg run_id "$RUN_ID" '{ "channel": "team-gnark-build", "text": "GitHub Action build result: success", "blocks": [ @@ -43,7 +50,7 @@ jobs: "text": { "type": "mrkdwn", "text": ":large_green_circle: *All checks have passed:* *\($branch)* :white_check_mark:" - }, + } }, { "type": "context", @@ -57,7 +64,7 @@ jobs: ] }') else - payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" '{ + payload=$(jq -n --arg repository "$REPOSITORY" --arg branch "$BRANCH" --arg actor "$ACTOR" --arg run_id "$RUN_ID" '{ "channel": "team-gnark-build", "text": "GitHub Action build result: failure", "blocks": [ @@ -66,7 +73,7 @@ jobs: "text": { "type": "mrkdwn", "text": ":red_circle: *Failed run:* *\($branch)*" - }, + } }, { "type": "context", @@ -80,5 +87,5 @@ jobs: ] }') fi - response=$(curl -s -X POST -H 'Content-type: application/json; charset=utf-8' --data "$payload" https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" ) + response=$(curl -s -X POST -H 'Content-type: application/json; charset=utf-8' --data "$payload" https://slack.com/api/chat.postMessage -H "Authorization: Bearer $SLACK_BOT_TOKEN" ) shell: bash