-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from mozilla-it/OPST-785
Opst 785
- Loading branch information
Showing
3 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Mozilla Deployment GitHub Actions | ||
|
||
This repository contains GitHub Actions Composite Actions used for Deployment Automation. |
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
# | ||
name: Slack notifications | ||
description: Slack notifications for deployments | ||
|
||
inputs: | ||
app_name: | ||
description: Name of tenant app_name to deploy to, e.g. testapp1 | ||
required: true | ||
type: string | ||
env_name: | ||
description: Name of tenant env to deploy to, e.g. dev | ||
required: true | ||
type: string | ||
type: | ||
description: Message type to be sent, supported values 'start', 'end', 'custom' | ||
required: true | ||
type: string | ||
channel_id: | ||
description: Slack channel id to send messages | ||
required: true | ||
type: string | ||
slack_bot_token: | ||
description: Slack bot token oauth secret | ||
required: true | ||
type: string | ||
ref: | ||
description: Deployment ref | ||
required: false | ||
type: string | ||
message: | ||
description: Custom message when inputs.type is set to 'custom' | ||
required: false | ||
type: string | ||
default: "" | ||
update_ts: | ||
description: Message ts for updating sent messages | ||
required: false | ||
type: string | ||
outputs: | ||
ts: | ||
description: Slack ts for updating messages | ||
value: ${{ steps.slack.outputs.ts }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- id: slack | ||
uses: slackapi/[email protected] | ||
env: | ||
SLACK_BOT_TOKEN: ${{ inputs.SLACK_BOT_TOKEN }} | ||
MESSAGE: >- | ||
{ | ||
"start": { | ||
"attachments": [ | ||
{ | ||
"color": "#dbab09", | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "${{ inputs.app_name }} ${{ inputs.env_name }}: Deploy started - ${{ inputs.ref }}" | ||
}, | ||
"accessory": { | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "Github Actions", | ||
"emoji": true | ||
}, | ||
"value": "click", | ||
"url": "${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}", | ||
"action_id": "button-action" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"end": { | ||
"attachments": [ | ||
{ | ||
"color": "#28a745", | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "${{ inputs.app_name }} ${{ inputs.env_name }}: Deploy complete - ${{ inputs.ref }}" | ||
}, | ||
"accessory": { | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "Github Actions", | ||
"emoji": true | ||
}, | ||
"value": "click", | ||
"url": "${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}", | ||
"action_id": "button-action" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"custom": { | ||
"text": "${{ inputs.app_name }} ${{ inputs.env_name }}: ${{ inputs.message }}", | ||
"attachments": [ | ||
{ | ||
"color": "#28a745", | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "${{ inputs.app_name }} ${{ inputs.env_name }}: ${{ inputs.message }}" | ||
}, | ||
"accessory": { | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "Github Actions", | ||
"emoji": true | ||
}, | ||
"value": "click", | ||
"url": "${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}", | ||
"action_id": "button-action" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
with: | ||
channel-id: ${{ inputs.channel_id }} | ||
payload: ${{ toJSON(fromJson(env.MESSAGE)[inputs.type]) }} | ||
update-ts: ${{ inputs.update_ts }} |