From 030a463eaa2bd9b0ce95c0805ddf5c2fea6e1662 Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Thu, 20 Oct 2022 13:01:50 -0400 Subject: [PATCH 1/3] Restructure directory to support multiple actions --- action.yaml => deploy/action.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename action.yaml => deploy/action.yaml (100%) diff --git a/action.yaml b/deploy/action.yaml similarity index 100% rename from action.yaml rename to deploy/action.yaml From 086f7bda13bbf2ffc93f173587cc101543726d93 Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Thu, 20 Oct 2022 13:02:16 -0400 Subject: [PATCH 2/3] Add slack composite action --- slack/action.yaml | 142 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 slack/action.yaml diff --git a/slack/action.yaml b/slack/action.yaml new file mode 100644 index 0000000..503839c --- /dev/null +++ b/slack/action.yaml @@ -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 }} From 7e59cb19de867f0c08b3b9fedece24165e63415c Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Thu, 20 Oct 2022 13:29:16 -0400 Subject: [PATCH 3/3] Add README --- README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..14a7d86 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Mozilla Deployment GitHub Actions + +This repository contains GitHub Actions Composite Actions used for Deployment Automation.