diff --git a/.github/workflows/doc-changes-workflow.yml b/.github/workflows/doc-changes-workflow.yml new file mode 100644 index 000000000..f4ce55fd1 --- /dev/null +++ b/.github/workflows/doc-changes-workflow.yml @@ -0,0 +1,46 @@ +# This workflow is designed to notify a given email address with pertinent information +# about changes to the Documentation files, using a cron-based trigger. + +name: Documentation Changes + +on: + # Schedule job to run at midnight UTC every Saturday + schedule: + - cron: "0 0 * * 6" + +jobs: + + script: + runs-on: ubuntu-latest + + steps: + - name: Checkout action + uses: actions/checkout@v2 + with: + # This is necessary as this script needs to examine all history and prepare an output + # report that defines all changes made to the Documentation within the last number of + # days. + fetch-depth: 0 + # Always run this against main + ref: 'main' + + - name: Run script + id: changes + run: | + ./github-support/notify-documentation-changes.sh "main" + CHANGES=$(cat documentation_changes.txt) + echo "CHANGES<> $GITHUB_ENV + echo "$CHANGES" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + - name: Send email notification + uses: zulip/github-actions-zulip/send-message@v1 + with: + api-key: ${{ secrets.ZULIP_TOKEN }} + email: ${{ secrets.ZULIP_TOKEN_EMAIL_ADDRESS }} + organization-url: "https://debezium.zulipchat.com" + to: "documentation" + type: "stream" + topic: "activity" + content: ${{ env.CHANGES }} + diff --git a/github-support/notify-documentation-changes.sh b/github-support/notify-documentation-changes.sh new file mode 100755 index 000000000..2a7341857 --- /dev/null +++ b/github-support/notify-documentation-changes.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -ouo > /dev/null 2>&1 + +GIT_SINCE="1.weeks" +GITHUB_COMMIT_URL="https://github.com/debezium/debezium/commit/" +OUTPUT="documentation_changes.txt" +GIT_OUTPUT_FILE="git_history.txt" +GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` + +# Get the history from Git +git log --pretty=oneline --follow --since=$GIT_SINCE -- documentation > $GIT_OUTPUT_FILE + +rm -f $OUTPUT +echo "The following Debezium documentation changes have been made in the last 7 days on branch \"$GIT_BRANCH\":" >> $OUTPUT +echo "" >> $OUTPUT + +while IFS=" " read -r COMMIT_SHA COMMIT_MSG +do + echo "* [$COMMIT_SHA]($GITHUB_COMMIT_URL$COMMIT_SHA)" >> $OUTPUT + echo "$COMMIT_MSG" >> $OUTPUT +done < $GIT_OUTPUT_FILE +rm -f $GIT_OUTPUT_FILE + +cat $OUTPUT \ No newline at end of file