@@ -675,170 +675,17 @@ jobs:
675675 timeout-minutes : 2
676676
677677 steps :
678- - name : Get commit message
679- id : commit
680- run : |
681- COMMIT_MSG=$(git log -1 --pretty=%B ${{ github.sha }} 2>/dev/null || echo "Commit message unavailable")
682- # Truncate to 100 chars and escape for JSON
683- COMMIT_MSG=$(echo "$COMMIT_MSG" | head -c 100 | sed 's/"/\\"/g' | tr -d '\n')
684- echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT
685- echo "short_sha=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
686-
687- - name : Send success notification
688- if : needs.deploy.result == 'success'
689- uses : slackapi/slack-github-action@v1.27.0
690- with :
691- channel-id : ${{ inputs.slack-channel }}
692- payload : |
693- {
694- "text": "✅ Deployment Successful: ${{ inputs.app-name }}",
695- "blocks": [
696- {
697- "type": "header",
698- "text": {
699- "type": "plain_text",
700- "text": "✅ Deployment Successful",
701- "emoji": true
702- }
703- },
704- {
705- "type": "section",
706- "fields": [
707- {
708- "type": "mrkdwn",
709- "text": "*App:*\n${{ inputs.app-name }}"
710- },
711- {
712- "type": "mrkdwn",
713- "text": "*Environment:*\nProduction"
714- },
715- {
716- "type": "mrkdwn",
717- "text": "*CDN:*\n<${{ inputs.cdn-url }}|${{ inputs.cdn-url }}>"
718- },
719- {
720- "type": "mrkdwn",
721- "text": "*Deployed by:*\n${{ github.actor }}"
722- },
723- {
724- "type": "mrkdwn",
725- "text": "*Commit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ steps.commit.outputs.short_sha }}>"
726- },
727- {
728- "type": "mrkdwn",
729- "text": "*Branch:*\n${{ github.ref_name }}"
730- }
731- ]
732- },
733- {
734- "type": "section",
735- "text": {
736- "type": "mrkdwn",
737- "text": "*Commit Message:*\n${{ steps.commit.outputs.message }}"
738- }
739- },
740- {
741- "type": "actions",
742- "elements": [
743- {
744- "type": "button",
745- "text": {
746- "type": "plain_text",
747- "text": "View Workflow"
748- },
749- "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
750- },
751- {
752- "type": "button",
753- "text": {
754- "type": "plain_text",
755- "text": "View Commit"
756- },
757- "url": "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}"
758- }
759- ]
760- }
761- ]
762- }
763- env :
764- SLACK_BOT_TOKEN : ${{ secrets.SLACK_OAUTH_TOKEN }}
765-
766- - name : Send failure notification
767- if : needs.deploy.result == 'failure'
768- uses : slackapi/slack-github-action@v1.27.0
678+ - name : Send deployment notification
679+ uses : Typeform/.github/shared-actions/slack-deployment-notification@v1
769680 with :
770- channel-id : ${{ inputs.slack-channel }}
771- payload : |
772- {
773- "text": "❌ Deployment Failed: ${{ inputs.app-name }}",
774- "blocks": [
775- {
776- "type": "header",
777- "text": {
778- "type": "plain_text",
779- "text": "❌ Deployment Failed",
780- "emoji": true
781- }
782- },
783- {
784- "type": "section",
785- "fields": [
786- {
787- "type": "mrkdwn",
788- "text": "*App:*\n${{ inputs.app-name }}"
789- },
790- {
791- "type": "mrkdwn",
792- "text": "*Environment:*\nProduction"
793- },
794- {
795- "type": "mrkdwn",
796- "text": "*Failed at:*\nDeploy job"
797- },
798- {
799- "type": "mrkdwn",
800- "text": "*Deployed by:*\n${{ github.actor }}"
801- },
802- {
803- "type": "mrkdwn",
804- "text": "*Commit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ steps.commit.outputs.short_sha }}>"
805- },
806- {
807- "type": "mrkdwn",
808- "text": "*Branch:*\n${{ github.ref_name }}"
809- }
810- ]
811- },
812- {
813- "type": "section",
814- "text": {
815- "type": "mrkdwn",
816- "text": ":warning: *Action Required:* Check the workflow logs for details."
817- }
818- },
819- {
820- "type": "actions",
821- "elements": [
822- {
823- "type": "button",
824- "text": {
825- "type": "plain_text",
826- "text": "View Logs"
827- },
828- "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
829- "style": "danger"
830- },
831- {
832- "type": "button",
833- "text": {
834- "type": "plain_text",
835- "text": "View Commit"
836- },
837- "url": "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}"
838- }
839- ]
840- }
841- ]
842- }
843- env :
681+ slack-channel : ${{ inputs.slack-channel }}
682+ app-name : ${{ inputs.app-name }}
683+ deployment-status : ${{ needs.deploy.result }}
684+ cdn-url : ${{ inputs.cdn-url }}
685+ github-sha : ${{ github.sha }}
686+ github-actor : ${{ github.actor }}
687+ github-ref-name : ${{ github.ref_name }}
688+ github-repository : ${{ github.repository }}
689+ github-server-url : ${{ github.server_url }}
690+ github-run-id : ${{ github.run_id }}
844691 SLACK_BOT_TOKEN : ${{ secrets.SLACK_OAUTH_TOKEN }}
0 commit comments