|
| 1 | +name: Notify Matrix on Tag |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + send-message: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + name: Send tag message via Matrix |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + |
| 18 | + - name: Get commits in tag |
| 19 | + id: commits |
| 20 | + run: | |
| 21 | + TAG="${{ github.ref_name }}" |
| 22 | + PREV_TAG=$(git tag --sort=-version:refname | grep -v "^${TAG}$" | head -n1) |
| 23 | +
|
| 24 | + if [ -z "$PREV_TAG" ]; then |
| 25 | + COMMIT_LOG=$(git log "${TAG}" --pretty=format:"- %s (%h)" | head -50) |
| 26 | + else |
| 27 | + COMMIT_LOG=$(git log "${PREV_TAG}..${TAG}" --pretty=format:"- %s (%h)" | head -50) |
| 28 | + fi |
| 29 | +
|
| 30 | + # Escape for GitHub output (multiline) |
| 31 | + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) |
| 32 | + echo "log<<${EOF}" >> "$GITHUB_OUTPUT" |
| 33 | + echo "$COMMIT_LOG" >> "$GITHUB_OUTPUT" |
| 34 | + echo "${EOF}" >> "$GITHUB_OUTPUT" |
| 35 | +
|
| 36 | + echo "prev_tag=${PREV_TAG}" >> "$GITHUB_OUTPUT" |
| 37 | +
|
| 38 | + - name: Send message to Matrix channel |
| 39 | + uses: fadenb/matrix-chat-message@89baab2b9ea06ffdd5f5b1ca80e9f888c3d7c9d3 # v0.0.6 |
| 40 | + with: |
| 41 | + homeserver: 'matrix.org' |
| 42 | + token: ${{ secrets.MATRIX_TOKEN }} |
| 43 | + channel: '!BjvpZgjrupiZgiIbGg:in.tum.de' |
| 44 | + message: | |
| 45 | + 🏷️ New release **${{ github.ref_name }}** created by ${{ github.event.sender.login }} |
| 46 | +
|
| 47 | + ## Commits${{ steps.commits.outputs.prev_tag && format(' since {0}', steps.commits.outputs.prev_tag) || '' }} |
| 48 | +
|
| 49 | + ${{ steps.commits.outputs.log }} |
| 50 | +
|
| 51 | + 🔗 https://github.com/${{ github.repository }}/compare/${{ steps.commits.outputs.prev_tag }}...${{ github.ref_name }} |
0 commit comments