Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opst 785 #5

Merged
merged 3 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/slack-github-action@v1.23.0
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 }}