Skip to content

Commit 8266c37

Browse files
authored
Merge pull request #41 from redis/release_automation
Modified slack script and uncommented slack action
2 parents d2e858c + 3b60d4d commit 8266c37

File tree

3 files changed

+50
-66
lines changed

3 files changed

+50
-66
lines changed

.github/actions/common/slack.sh

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
slack_format_success_message() {
44
jq --arg release_tag "$1" --arg url_prefix "$2" --arg footer "$3" --arg env "$4" '
5-
def generate_repo_prefix(package_name):
6-
package_name[:1] + "/" + package_name[:2];
75
{
86
"icon_emoji": ":redis-circle:",
97
"text": (":homebrew: Homebrew Packages Published for Redis: " + $release_tag + " (" + $env + ")"),
@@ -21,28 +19,13 @@ def generate_repo_prefix(package_name):
2119
}
2220
}
2321
] +
24-
(
25-
to_entries
26-
| map(
27-
. as $dist_entry |
28-
.value | to_entries
29-
| map({
30-
"type": "section",
31-
"text": {
32-
"type": "mrkdwn",
33-
"text": (
34-
"Distribution: *" + $dist_entry.key + "* | Architecture: *" + .key + "*\n" +
35-
(
36-
.value
37-
| map("• <" + $url_prefix + "/" + $dist_entry.key + "/" + generate_repo_prefix(.) + "/" + . + "|" + . + ">")
38-
| join("\n")
39-
)
40-
)
41-
}
42-
})
43-
)
44-
| flatten
45-
) +
22+
map({
23+
"type": "section",
24+
"text": {
25+
"type": "mrkdwn",
26+
"text": ("Architecture: *" + . + "*\n• <" + $url_prefix + "/redis-oss-" + $release_tag + "-" + . + ".zip|redis-oss-" + $release_tag + "-" + . + ".zip>")
27+
}
28+
}) +
4629
[
4730
{
4831
"type": "context",
@@ -54,6 +37,7 @@ def generate_repo_prefix(package_name):
5437
)
5538
}'
5639
}
40+
5741
slack_format_failure_message() {
5842
header=$1
5943
workflow_url=$2

.github/workflows/release_build_and_test.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,25 @@ jobs:
7878

7979
# Notify only about build failures
8080
# as publish workflow will notify about publish success or failure
81-
# slack-failure-notification:
82-
# needs: build-n-test
83-
# runs-on: ubuntu-latest
84-
# if: failure()
85-
# steps:
86-
# - name: Detect env name
87-
# id: detect-env
88-
# run: |
89-
# if [ "${{ inputs.release_type }}" = "public" ]; then
90-
# env_name="production"
91-
# elif [ "${{ inputs.release_type }}" = "internal" ]; then
92-
# env_name="staging"
93-
# fi
94-
# echo "env_name=$env_name" >> $GITHUB_OUTPUT
95-
# - name: Send Failure Slack notification
96-
# uses: ./.github/actions/slack-notification
97-
# with:
98-
# slack_func: slack_format_failure_message
99-
# release_tag: ${{ github.event.inputs.release_tag }}
100-
# env: ${{ steps.detect-env.outputs.env_name }}
101-
# message: ":homebrew: Homebrew package build failed"
102-
# SLACK_WEB_HOOK_URL: ${{ secrets.SLACK_WEB_HOOK_URL }}
81+
slack-failure-notification:
82+
needs: build-n-test
83+
runs-on: ubuntu-latest
84+
if: failure()
85+
steps:
86+
- name: Detect env name
87+
id: detect-env
88+
run: |
89+
if [ "${{ inputs.release_type }}" = "public" ]; then
90+
env_name="production"
91+
elif [ "${{ inputs.release_type }}" = "internal" ]; then
92+
env_name="staging"
93+
fi
94+
echo "env_name=$env_name" >> $GITHUB_OUTPUT
95+
- name: Send Failure Slack notification
96+
uses: ./.github/actions/slack-notification
97+
with:
98+
slack_func: slack_format_failure_message
99+
release_tag: ${{ github.event.inputs.release_tag }}
100+
env: ${{ steps.detect-env.outputs.env_name }}
101+
message: ":homebrew: Homebrew package build failed"
102+
SLACK_WEB_HOOK_URL: ${{ secrets.SLACK_WEB_HOOK_URL }}

.github/workflows/release_publish.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,23 @@ jobs:
120120
path: result.json
121121
retention-days: 90
122122

123-
# - name: Send Success Slack notification
124-
# uses: ./.github/actions/slack-notification
125-
# with:
126-
# slack_func: slack_format_success_message
127-
# release_tag: ${{ github.event.inputs.release_tag }}
128-
# url_prefix: ${{ steps.validate-inputs.outputs.url_prefix }}
129-
# env: ${{ steps.validate-inputs.outputs.env_name }}
130-
# packages_json: ${{ steps.upload.outputs.packages_json }}
131-
# SLACK_WEB_HOOK_URL: ${{ secrets.SLACK_WEB_HOOK_URL }}
132-
#
133-
# - name: Send Failure Slack notification
134-
# if: failure()
135-
# uses: ./.github/actions/slack-notification
136-
# with:
137-
# slack_func: slack_format_failure_message
138-
# release_tag: ${{ github.event.inputs.release_tag }}
139-
# env: ${{ steps.validate-inputs.outputs.env_name }}
140-
# packages_json: ${{ steps.upload.outputs.packages_json }}
141-
# message: ":debian: Debian package upload failed"
142-
# SLACK_WEB_HOOK_URL: ${{ secrets.SLACK_WEB_HOOK_URL }}
123+
- name: Send Success Slack notification
124+
uses: ./.github/actions/slack-notification
125+
with:
126+
slack_func: slack_format_success_message
127+
release_tag: ${{ github.event.inputs.release_tag }}
128+
url_prefix: ${{ steps.validate-inputs.outputs.url_prefix }}
129+
env: ${{ steps.validate-inputs.outputs.env_name }}
130+
packages_json: ${{ steps.upload.outputs.packages_json }}
131+
SLACK_WEB_HOOK_URL: ${{ secrets.SLACK_WEB_HOOK_URL }}
132+
133+
- name: Send Failure Slack notification
134+
if: failure()
135+
uses: ./.github/actions/slack-notification
136+
with:
137+
slack_func: slack_format_failure_message
138+
release_tag: ${{ github.event.inputs.release_tag }}
139+
env: ${{ steps.validate-inputs.outputs.env_name }}
140+
packages_json: ${{ steps.upload.outputs.packages_json }}
141+
message: ":homebrew: Homebrew package upload failed"
142+
SLACK_WEB_HOOK_URL: ${{ secrets.SLACK_WEB_HOOK_URL }}

0 commit comments

Comments
 (0)