-
Notifications
You must be signed in to change notification settings - Fork 2k
85 lines (79 loc) · 2.69 KB
/
updates-notification.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Send update notification
on:
workflow_call:
inputs:
tag:
required: true
type: string
version:
required: true
type: string
image_digest:
required: true
type: string
slack_webhook_url:
required: true
type: string
defaults:
run:
shell: bash
permissions:
contents: read
jobs:
send-notifications:
name: Send Notifications
runs-on: ubuntu-22.04
permissions:
contents: read
actions: read # for 8398a7/action-slack
steps:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: refs/tags/v${{ inputs.tag }}
- name: Get variables for Slack
id: slack
run: |
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
echo "date=$(date +%s)" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "sha_long=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Send Notification
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: custom
custom_payload: |
{
username: "Docker",
icon_emoji: ":docker:",
mention: "here",
attachments: [{
title: `New Docker image was pushed to DockerHub for ${process.env.AS_REPO}`,
color: "good",
fields: [{
title: "Docker Image",
value: `<https://hub.docker.com/r/nginx/nginx-ingress/tags?page=1&ordering=last_updated&name=${{ inputs.tag }}|nginx/nginx-ingress:${{ inputs.version }}>`,
short: true
},
{
title: "Image digest",
value: "${{ inputs.image_digest }}",
short: true
},
{
title: "Commit Message",
value: `${{ steps.slack.outputs.message }}`,
short: true
},
{
title: "Commit Hash",
value: `<https://github.com/${{ github.repository }}/commit/${{ steps.slack.outputs.sha_long }}|${{ steps.slack.outputs.sha_short }}>`,
short: true
}],
footer: "Update DockerHub Image",
footer_icon: "https://raw.githubusercontent.com/docker-library/docs/c350af05d3fac7b5c3f6327ac82fe4d990d8729c/docker/logo.png",
ts: ${{ steps.slack.outputs.date }}
}]
}
env:
SLACK_WEBHOOK_URL: ${{ inputs.slack_webhook_url }}