Skip to content

Commit

Permalink
Merge pull request #5 from mozilla-it/OPST-785
Browse files Browse the repository at this point in the history
Opst 785
  • Loading branch information
jasonthomas authored Oct 20, 2022
2 parents 33b4315 + 7e59cb1 commit 6561a48
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
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.
142 changes: 142 additions & 0 deletions slack/action.yaml
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 }}

0 comments on commit 6561a48

Please sign in to comment.