# 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@v4 with: persist-credentials: false - name: Find correspondences id: email uses: slackapi/slack-github-action@v2.1.1 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/slack-github-action@v2.1.1 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: : `${{ github.sha }}`" } }, { "type": "section", "text": { "type": "mrkdwn", "text": ${{ toJSON(github.event.head_commit.message) }} } } ]