Skip to content

Commit a2badff

Browse files
authored
add slack notifications to release workflow (nginx#5751)
1 parent 31c7f3a commit a2badff

File tree

1 file changed

+97
-35
lines changed

1 file changed

+97
-35
lines changed

.github/workflows/release.yml

Lines changed: 97 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,11 @@ jobs:
372372
if: ${{ ! contains(inputs.skip_step, 'github-release') }}
373373
name: Publish release to GitHub
374374
runs-on: ubuntu-22.04
375-
needs: [variables, binaries, release-oss, release-plus]
375+
needs: [variables, binaries, release-oss, release-plus, azure-upload]
376376
permissions:
377377
contents: write # to modify the release
378378
issues: write # to close milestone
379+
actions: read # for slack notification
379380
steps:
380381
- name: Checkout Repository
381382
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
@@ -446,37 +447,98 @@ jobs:
446447
RELEASE_ID: ${{ steps.release-id.outputs.release_id }}
447448
if: ${{ ! inputs.dry_run }}
448449

449-
# release-image-notification:
450-
# if: ${{ ! inputs.dry_run && ! contains(inputs.skip_step, 'release-image-notification') }}
451-
# name: Notify Slack channels about image release
452-
# runs-on: ubuntu-22.04
453-
# needs: [variables, binaries, release-oss, release-plus]
454-
# permissions:
455-
# contents: read
456-
# actions: read
457-
# strategy:
458-
# fail-fast: false
459-
# matrix:
460-
# image: ["nginx/nginx-ingress:${{ inputs.nic_version }}", "nginx/nginx-ingress:${{ inputs.nic_version }}-ubi", "nginx/nginx-ingress:${{ inputs.nic_version }}-alpine"]
461-
# steps:
462-
# - name: Checkout Repository
463-
# uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
464-
# with:
465-
# ref: ${{ inputs.release_branch }}
466-
467-
# - name: Get Image manifest digest
468-
# id: digest
469-
# run: |
470-
# digest=$(docker buildx imagetools inspect ${{ matrix.image }} --format '{{ json . }}' | jq -r .manifest.digest)
471-
472-
# - name: Get Image tag
473-
# id: tag
474-
# run: |
475-
# tag=$(echo ${{ matrix.image }} | cut -d ':' -f 2)
476-
477-
# - name: Notify Slack of Dockerhub image release
478-
# uses: ./.github/workflows/updates-notification.yml
479-
# with:
480-
# tag: ${{ steps.tag.outputs.tag }}
481-
# version: ${{ inputs.nic_version }}
482-
# image_digest: ${{ steps.digest.outputs.digest }}
450+
- name: Send Notification
451+
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
452+
with:
453+
status: custom
454+
custom_payload: |
455+
{
456+
"blocks": [
457+
{
458+
"type": "section",
459+
"text": {
460+
"type": "mrkdwn",
461+
"text": "NGINX Ingress Controller v${{ inputs.nic_version }} is out! Check it out: https://github.com/nginxinc/kubernetes-ingress/releases/tag/v${{ inputs.nic_version }}"
462+
}
463+
}
464+
]
465+
}
466+
env:
467+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_COMMUNITY }}
468+
if: ${{ ! inputs.dry_run }}
469+
470+
release-image-notification:
471+
if: ${{ ! inputs.dry_run && ! contains(inputs.skip_step, 'release-image-notification') }}
472+
name: Notify Slack channels about image release
473+
runs-on: ubuntu-22.04
474+
needs: [variables, binaries, release-oss, release-plus]
475+
permissions:
476+
contents: read
477+
actions: read
478+
strategy:
479+
fail-fast: false
480+
matrix:
481+
image: ["nginx/nginx-ingress:${{ inputs.nic_version }}", "nginx/nginx-ingress:${{ inputs.nic_version }}-ubi", "nginx/nginx-ingress:${{ inputs.nic_version }}-alpine"]
482+
steps:
483+
- name: Checkout Repository
484+
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
485+
with:
486+
ref: ${{ inputs.release_branch }}
487+
488+
- name: Get Image manifest digest
489+
id: digest
490+
run: |
491+
digest=$(docker buildx imagetools inspect ${{ matrix.image }} --format '{{ json . }}' | jq -r .manifest.digest)
492+
493+
- name: Get Image tag
494+
id: tag
495+
run: |
496+
tag=$(echo ${{ matrix.image }} | cut -d ':' -f 2)
497+
498+
- name: Get variables for Slack
499+
id: slack
500+
run: |
501+
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
502+
echo "date=$(date +%s)" >> $GITHUB_OUTPUT
503+
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
504+
echo "sha_long=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
505+
506+
- name: Send Notification
507+
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
508+
with:
509+
status: custom
510+
custom_payload: |
511+
{
512+
username: "Docker",
513+
icon_emoji: ":docker:",
514+
mention: "here",
515+
attachments: [{
516+
title: `New Docker image was pushed to DockerHub for ${process.env.AS_REPO}`,
517+
color: "good",
518+
fields: [{
519+
title: "Docker Image",
520+
value: `<https://hub.docker.com/r/nginx/nginx-ingress/tags?page=1&ordering=last_updated&name=${{ steps.tag.outputs.tag }}|nginx/nginx-ingress:${{ inputs.nic_version }}>`,
521+
short: true
522+
},
523+
{
524+
title: "Image digest",
525+
value: "${{ steps.digest.outputs.digest }}",
526+
short: true
527+
},
528+
{
529+
title: "Commit Message",
530+
value: `${{ steps.slack.outputs.message }}`,
531+
short: true
532+
},
533+
{
534+
title: "Commit Hash",
535+
value: `<https://github.com/${{ github.repository }}/commit/${{ steps.slack.outputs.sha_long }}|${{ steps.slack.outputs.sha_short }}>`,
536+
short: true
537+
}],
538+
footer: "Update DockerHub Image",
539+
footer_icon: "https://raw.githubusercontent.com/docker-library/docs/c350af05d3fac7b5c3f6327ac82fe4d990d8729c/docker/logo.png",
540+
ts: ${{ steps.slack.outputs.date }}
541+
}]
542+
}
543+
env:
544+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

0 commit comments

Comments
 (0)