Created
June 2, 2024 10:30
-
-
Save konarskis/fe12d0d3a3a6d026cddf73af5033eb40 to your computer and use it in GitHub Desktop.
Organization-wide GitHub release notifications to Slack - Versioned
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create a new release (manual versioning) | |
# Creates a new release on GitHub using the specified version. | |
# Sends a Slack notification to the specified channel. | |
# Only use for the versioned release workflow. | |
on: | |
workflow_call: | |
inputs: | |
name: | |
description: | | |
The name of the product or project. | |
type: string | |
required: true | |
version: | |
description: | | |
The specific version of the release in the x.x.x format. | |
type: string | |
required: true | |
jobs: | |
create-release-versioned: | |
runs-on: ubuntu-latest | |
concurrency: create-release | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Fail if the version already exists | |
run: | | |
git fetch --all --tags | |
if git rev-list "v${{ inputs.version }}"; then exit 1; else exit 0; fi | |
- name: Retrieve merged PR details | |
uses: actions-ecosystem/action-get-merged-pull-request@v1 | |
id: get-merged-pull-request | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push the new release tag | |
run: | | |
tag="v${{ inputs.version }}" | |
message="Release v${{ inputs.version }}" | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git tag -a "${tag}" -m "${message}" | |
git push origin "${tag}" | |
- name: Create a Github release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ inputs.version }}" | |
release_name: "v${{ inputs.version }}" | |
body: ${{ steps.get-merged-pull-request.outputs.body }} | |
- name: Notify Slack release channel | |
uses: rtCamp/[email protected] | |
env: | |
SLACK_USERNAME: Github | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL_PRODUCT_RELEASES }} | |
SLACK_ICON: https://media.licdn.com/dms/image/D4E0BAQFCEMS33QQdVA/company-logo_200_200/0/1684235094312/savagescorp_logo?e=2147483647&v=beta&t=Zhp5NFU_HniXcECTjquQwQeGnINW1TwFh7ONK-ZXbqI | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_TITLE: "${{ inputs.name }} v${{ inputs.version }}" | |
SLACK_MESSAGE: ${{ steps.get-merged-pull-request.outputs.body }} | |
SLACK_FOOTER: "" | |
MSG_MINIMAL: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment