Created
June 2, 2024 10:29
-
-
Save konarskis/d403f3d356f990abbcbb77e2e55c9433 to your computer and use it in GitHub Desktop.
Organization-wide GitHub release notifications to Slack - Unversioned
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 (auto versioning) | |
| # Automatically bumps a version number and creates a new release on GitHub. | |
| # Sends a Slack notification to the specified channel. | |
| # Only use when not using the versioned release workflow. | |
| on: | |
| workflow_call: | |
| inputs: | |
| name: | |
| description: | | |
| The name of the product or project. | |
| type: string | |
| required: true | |
| jobs: | |
| create-release-unversioned: | |
| runs-on: ubuntu-latest | |
| concurrency: create-release | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - 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: Get the latest release tag | |
| uses: actions-ecosystem/action-get-latest-tag@v1 | |
| id: get-latest-tag | |
| - name: Bump the patch version number | |
| uses: actions-ecosystem/action-bump-semver@v1 | |
| id: bump-semver | |
| with: | |
| current_version: ${{ steps.get-latest-tag.outputs.tag }} | |
| level: patch | |
| - name: Push the new release tag | |
| run: | | |
| tag=${{ steps.bump-semver.outputs.new_version }} | |
| message="Release ${{ steps.bump-semver.outputs.new_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: ${{ steps.bump-semver.outputs.new_version }} | |
| release_name: ${{ steps.bump-semver.outputs.new_version }} | |
| body: ${{ steps.get-merged-pull-request.outputs.body }} | |
| - name: Notify Slack release channel | |
| uses: rtCamp/action-slack-notify@v2.3.0 | |
| 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 }} ${{ steps.bump-semver.outputs.new_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