Files
renovate/.github/workflows/mend-slack.yml
Jamie Tanna 0bc5849acd ci(mend-slack): pass discussion timestamp to script via env
To avoid potentially expanding a `discussion.created_at` event, we can
make sure we don't interpolate it, by injecting it in via `env`.

Co-authored-by: Claude Fable 5 <jamie.tanna+claude-code@mend.io>
2026-08-18 11:04:13 +01:00

45 lines
1.4 KiB
YAML

name: 'Mend Slack Notifier'
on:
discussion:
types: [created, labeled]
permissions:
discussions: read
jobs:
slack:
if: >
(github.event.action == 'created' && contains(github.event.discussion.labels.*.name, 'mend-app')) ||
(github.event.action == 'labeled' && github.event.label.name == 'mend-app')
runs-on: ubuntu-slim
steps:
- name: Calculate time ago
id: timeago
env:
CREATED_AT: ${{ github.event.discussion.created_at }}
run: |
created_at="$CREATED_AT"
created_epoch=$(date -d "$created_at" "+%s")
now_epoch=$(date +%s)
diff=$((now_epoch - created_epoch))
if [ $diff -lt 86400 ]; then
hours=$((diff / 3600))
echo "ago=$hours hours ago" >> "$GITHUB_OUTPUT"
else
days=$((diff / 86400))
echo "ago=$days days ago" >> "$GITHUB_OUTPUT"
fi
- name: Post to Slack
id: slack
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
with:
method: chat.postMessage
payload: |
channel: 'C05NLTMGCJC'
text: ${{ toJSON(format('<{0}|{1}> ({2}, {3})', github.event.discussion.html_url, github.event.discussion.title, github.event.discussion.created_at, steps.timeago.outputs.ago)) }}
errors: true
token: ${{ secrets.SLACK_BOT_TOKEN }}