I've added github action that sends a message on our slack channel on every release.
I've managed to get repo name and tag from github context, but I'm also trying and failing to get release title and release notes in that message. I've tried these combinations:
${{ github.event.payload.release.name || github.event.payload.release || github.event.payload }}
Does anyone know how to resolve this problem?
name: Release
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Sbt
uses: olafurpg/setup-scala@v10
- name: Set library version
run: ./sbt dynver
- name: Publish stable version
run: ./sbt publish
env:
JFROG_PASSWORD: ${{ secrets.JFROG_PASSWORD }}
- name: Post to a Slack channel
id: slack
uses: slackapi/slack-github-action@v1.17.0
with:
channel-id: 'releases'
slack-message: "Release result: ${{ job.status }}\n${{ github.repository }}: ${{ github.ref_name }}\nRelease info: ${{ github.event.payload.release.name }}, ${{ github.event.payload.release }} ${{ github.event.payload }}"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
Instead of triggering on the tag, trigger on the release creation. That way the release information will be present.
on:
release:
types: [published]
The tag will be under github.event.release.tag_name
, the release under github.event.release.name
.
Tags can be created independently of releases, that's why.
See: