Skip to content

Commit

Permalink
add Zulip notify
Browse files Browse the repository at this point in the history
  • Loading branch information
ab77 committed Mar 27, 2024
1 parent 7997ade commit cb3b4b8
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/flowzone.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ jobs:
]
release_notes: true
release_notes_zulip_stream: balena-io/internal-tooling
release_notes_zulip_topic: "Flowzone tests"
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,16 @@ jobs:
# Required: false
release_notes: false

# Zulip stream to notify.
# Type: string
# Required: false
release_notes_zulip_stream:

# Send release notes to this Zulip topic whin the stream.
# Type: string
# Required: false
release_notes_zulip_topic:


```
<!-- end usage -->
Expand Down
34 changes: 34 additions & 0 deletions flowzone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,14 @@ on:
type: boolean
required: false
default: false
release_notes_zulip_stream:
description: "Zulip stream to notify."
type: string
required: false
release_notes_zulip_topic:
description: "Send release notes to this Zulip topic whin the stream."
type: string
required: false

# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
Expand Down Expand Up @@ -1198,6 +1206,7 @@ jobs:
echo "$response" | jq .
echo "sha=$(echo $response | jq -r .sha)" >> $GITHUB_OUTPUT
echo "json=$(echo $response | jq -c .)" >> $GITHUB_OUTPUT
echo "bot=$(echo $response | jq -r .author.name | sed 's/\[bot\]//g')" >> $GITHUB_OUTPUT
# https://docs.github.com/en/rest/git/tags?apiVersion=2022-11-28#create-a-tag-object
- name: Create tag object
Expand Down Expand Up @@ -1277,6 +1286,31 @@ jobs:
env:
REF: '/repos/$GH_REPO/git/refs/tags/production-${{ steps.timestamp.outputs.datetime }}'

- name: Notify stream
if: |
github.event.pull_request.merged == true
&& inputs.disable_versioning != true
&& inputs.release_notes == true
&& inputs.release_notes_zulip_stream != ''
&& inputs.release_notes_zulip_topic != ''
&& vars.FLOWZONE_ZULIP_BOT_EMAIL != ''
continue-on-error: true
env:
GH_TOKEN: ${{ steps.gh_app_token.outputs.token || secrets.FLOWZONE_TOKEN }}
run: |
comment="$(gh pr view --json comments \
--jq '.[].[] | select(.author.login=="${{ steps.create_commit.outputs.bot }}").body')"
if [[ -n "$comment" ]] && [[ -n '${{ secrets.FLOWZONE_ZULIP_API_KEY }}' ]]; then
# https://zulip.com/api/send-message
curl -X POST https://balena.zulipchat.com/api/v1/messages \
-u ${{ vars.FLOWZONE_ZULIP_BOT_EMAIL }}:${{ secrets.FLOWZONE_ZULIP_API_KEY }} \
--data-urlencode type=stream \
--data-urlencode 'to="${{ inputs.release_notes_zulip_stream }}"' \
--data-urlencode topic=${{ inputs.release_notes_zulip_topic }} \
--data-urlencode "content=${comment}"
fi
# check if the repository has a package.json file and which engine versions are supported
is_npm:
name: Is npm
Expand Down

0 comments on commit cb3b4b8

Please sign in to comment.