Skip to content

build-completed

build-completed #70

Workflow file for this run

---
name: build-completed
on:
workflow_run:
workflows: ['build']
types: ['completed']
# branches: ['trunk', '*.*-stable']
# tags: ['trac-*']
jobs:
build-completed:
# if: ${{ github.event_name == 'push' && github.repository == 'edgewall/trac' }}
runs-on: ubuntu-22.04
steps:
- name: Send summary of the workflow run
env:
GH_TOKEN: ${{ github.token }}
RUN_ID: ${{ github.event.workflow_run.id }}
RUN_NAME: ${{ github.event.workflow_run.name }}
RUN_URL: ${{ github.event.workflow_run.html_url }}
RUN_SHA: ${{ github.event.workflow_run.head_sha }}
RUN_BRANCH: ${{ github.event.workflow_run.head_branch }}
RUN_CONCLUSION: ${{ github.event.workflow_run.conclusion }}
RUN_MESSAGE: ${{ github.event.workflow_run.head_commit.message }}
RUN_NUMBER: ${{ github.event.workflow_run.run_number }}
RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
RUN_UPDATED_AT: ${{ github.event.workflow_run.updated_at }}
SMTP_URL: ${{ secrets.SMTP_URL }}
SMTP_USER: ${{ secrets.SMTP_USER }}
SMTP_MAIL_FROM: ${{ secrets.SMTP_MAIL_FROM }}
SMTP_MAIL_RCPT: ${{ secrets.SMTP_MAIL_RCPT }}
if: ${{ env.SMTP_URL != null }}
run: |
set -ex
rev="$(echo -n "$RUN_MESSAGE" | sed -n '/^git-svn-id:/ { s/.*@\([0-9]*\) .*/r\1/; p; q }')"
[ -z "$rev" ] && rev="$(expr substr "$RUN_SHA" 1 9)"
repos="$GITHUB_REPOSITORY"
label="$RUN_NAME #$RUN_NUMBER"
if [ "$RUN_ATTEMPT" -ne 1 ]; then
label="$label, attempt #$RUN_ATTEMPT"
fi
msgid="github.com/$repos/run/$RUN_ID/$RUN_ATTEMPT@${SMTP_MAIL_FROM#*@}"
date="$(TZ=UTC date -R -d "$RUN_UPDATED_AT")"
tmpfile="$(mktemp)"
{
echo "From: <$SMTP_MAIL_FROM>"
echo "To: <$SMTP_MAIL_RCPT>"
echo "Date: $date"
echo "Message-ID: <$msgid>"
echo "Content-Type: text/plain; charset=utf-8"
echo "Content-Transfer-Encoding: 8bit"
echo "Subject: [$repos] Run $RUN_CONCLUSION: $label - $RUN_BRANCH ($rev)"
echo
echo "View this run on GitHub: $RUN_URL"
gh run view "$RUN_ID" --repo "$repos"
} >"$tmpfile"
case "$SMTP_URL" in
smtps:*) ssl_reqd=--ssl-reqd ;;
*) ssl_reqd= ;;
esac
curl --url "$SMTP_URL" $ssl_reqd --user "$SMTP_USER" \
--mail-from "$SMTP_MAIL_FROM" --mail-rcpt "$SMTP_MAIL_RCPT" \
--upload-file "$tmpfile"