v2.1.0 add codewatchers_ref config option #7
This file contains 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: Commit Notify | |
on: push | |
jobs: | |
get-notifications: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check commits | |
id: check | |
uses: yrtimiD/github-codewatchers@main | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
sha_from: ${{ github.event.before }} | |
sha_to: ${{ github.event.after }} | |
codewatchers: .github/CODEWATCHERS | |
ignore_own: false | |
outputs: | |
notifications: ${{ steps.check.outputs.notifications }} | |
sent-emails: | |
needs: get-notifications | |
runs-on: ubuntu-latest | |
name: ${{ join(matrix.notif.watchers.*.email,'; ') }} | |
strategy: | |
matrix: | |
notif: ${{ fromJSON(needs.get-notifications.outputs.notifications) }} | |
steps: | |
- name: Compose email | |
id: compose | |
run: | | |
set -e | |
EMAIL_TO='${{ join(matrix.notif.watchers.*.email,'; ') }}' | |
SHA=${{ matrix.notif.commit.sha }} | |
SUBJ=$(echo "${{ matrix.notif.commit.commit.message }}" | head -1) | |
EMAIL_SUBJ="[$GITHUB_REPOSITORY] ${SHA:0:10} $SUBJ" | |
FILES=$( echo '${{ toJSON(matrix.notif.commit.files) }}' | jq --raw-output '.[].filename | select(. != null)' ) | |
EMAIL_BODY=$(cat <<- ___EOF___ | |
Author: ${{ matrix.notif.commit.commit.author.name }} ${{ matrix.notif.commit.commit.author.email }} | |
Message: ${{ matrix.notif.commit.commit.message }} | |
Files: | |
$FILES | |
Commit: ${{ matrix.notif.commit.html_url }} | |
___EOF___ | |
) | |
echo "To: $EMAIL_TO" | |
echo "Subj: $EMAIL_SUBJ" | |
echo "Body: $EMAIL_BODY" | |
echo to="$EMAIL_TO" >> $GITHUB_OUTPUT | |
echo subj="$EMAIL_SUBJ" >> $GITHUB_OUTPUT | |
echo "body<<___EOF___" >> $GITHUB_OUTPUT | |
echo "$EMAIL_BODY" >> $GITHUB_OUTPUT | |
echo "___EOF___" >> $GITHUB_OUTPUT | |
- uses: cinotify/github-action@main | |
with: | |
to: ${{ steps.compose.outputs.to }} | |
subject: ${{ steps.compose.outputs.subj }} | |
body: ${{ steps.compose.outputs.body }} |