Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Eden Zimbelman <[email protected]>
57 lines
1.9 KiB
YAML
57 lines
1.9 KiB
YAML
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
|
|
|
|
name: Direct message the author
|
|
on:
|
|
push:
|
|
jobs:
|
|
run:
|
|
name: Send a notification of recent changes
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout the repo
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Find correspondences
|
|
id: email
|
|
uses: slackapi/[email protected]
|
|
with:
|
|
method: users.lookupByEmail # https://docs.slack.dev/reference/methods/users.lookupByEmail/
|
|
token: ${{ secrets.SLACK_BOT_TOKEN }}
|
|
payload: |
|
|
email: ${{ github.event.pusher.email }}
|
|
|
|
- name: Search email detail
|
|
if: ${{ steps.email.outputs.ok }}
|
|
run: |
|
|
SLACK_USER_ID=$(echo '${{ steps.email.outputs.response }}' | jq -r '.user.id')
|
|
echo "SLACK_USER_ID=$SLACK_USER_ID" >> $GITHUB_ENV
|
|
|
|
- name: Send a direct message
|
|
if: ${{ steps.email.outputs.ok }}
|
|
uses: slackapi/[email protected]
|
|
with:
|
|
errors: true
|
|
method: chat.postMessage # https://docs.slack.dev/reference/methods/chat.postMessage/
|
|
token: ${{ secrets.SLACK_BOT_TOKEN }}
|
|
payload: |
|
|
"channel": "${{ env.SLACK_USER_ID }}",
|
|
"text": "${{ github.repository }} had a change!",
|
|
"blocks": [
|
|
{
|
|
"type": "section",
|
|
"text": {
|
|
"type": "mrkdwn",
|
|
"text": ":large_green_square: <https://github.com/${{ github.repository }}|*${{ github.repository }}*>: `${{ github.sha }}`"
|
|
}
|
|
},
|
|
{
|
|
"type": "section",
|
|
"text": {
|
|
"type": "mrkdwn",
|
|
"text": ${{ toJSON(github.event.head_commit.message) }}
|
|
}
|
|
}
|
|
]
|