search results: use title as fallback if snippet is null #78
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: Slack Release Notification | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
checkType: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Find last merge | |
run: | | |
echo "current_commit=$(git log --pretty='%H' -1)" >> $GITHUB_ENV | |
echo "last_merge=$(git log --pretty='%H' --merges -1 --first-parent)" >> $GITHUB_ENV | |
outputs: | |
last_merge: ${{ env.last_merge }} | |
current_commit: ${{ env.current_commit }} | |
directCommit: | |
runs-on: ubuntu-latest | |
needs: checkType | |
if: needs.checkType.outputs.last_merge != needs.checkType.outputs.current_commit | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: get commit message | |
run: | | |
message=$(git log --pretty=':exclamation: direct commit to main %h by %an (%ae) - %s %b' -1) | |
echo "$message" | |
echo 'message<<EOF' >> $GITHUB_ENV | |
echo "$message" >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
outputs: | |
message: ${{ env.message }} | |
mergeCommit: | |
runs-on: ubuntu-latest | |
needs: checkType | |
if: needs.checkType.outputs.last_merge == needs.checkType.outputs.current_commit | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: get commit messages | |
run: | | |
previous_merge=$(git log --pretty="%h" -1 --merges --skip=1 --first-parent) | |
echo $previous_merge | |
message=$(git log --pretty="-> %h by %an (%ae) - %s %b" --no-merges $previous_merge..${{ needs.checkType.outputs.last_merge }}) | |
echo "$message" | |
direct_commits=$(git log --pretty="%h" --no-merges --first-parent $previous_merge..${{ needs.checkType.outputs.last_merge }}) | |
while IFS= read -r direct_commit; do | |
if [[ ! -z "$direct_commit" ]]; then | |
echo "$direct_commit" | |
message=$(echo "$message" | grep -v $direct_commit) | |
fi | |
done <<< "$direct_commits" | |
echo "$message" | |
echo 'message<<EOF' >> $GITHUB_ENV | |
echo ':merge: new code version released:' >> $GITHUB_ENV | |
echo "$message" >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
outputs: | |
message: ${{ env.message }} | |
slack: | |
runs-on: ubuntu-latest | |
needs: [directCommit, mergeCommit] | |
if: ${{ !failure() }} | |
steps: | |
# the following action is based on a workflow created by Andreas Haller, contact for permissions, the workflow file to import can be found under tools/slack | |
- name: Notify Slack | |
uses: slackapi/[email protected] | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }} | |
with: | |
payload: | | |
{ | |
"text": ${{ toJson(needs.directCommit.outputs.message || needs.mergeCommit.outputs.message) }} | |
} |