Skip to content

Commit bfbc9ac

Browse files
committed
Send a message to Zulip when a sync finishes
1 parent 8c5b8fa commit bfbc9ac

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

.github/workflows/rustc-pull.yml

+33-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
pull:
1111
if: github.repository == 'rust-lang/rustc-dev-guide'
1212
runs-on: ubuntu-latest
13+
outputs:
14+
pr_url: ${{ steps.update-pr.outputs.pr_url }}
1315
permissions:
1416
contents: write
1517
pull-requests: write
@@ -40,16 +42,45 @@ jobs:
4042
git switch -c $BRANCH
4143
git push -u origin $BRANCH --force
4244
- name: Create pull request
45+
id: update-pr
4346
run: |
47+
# TODO: pr_number GITHUB_OUTPUT
4448
# Check if an open pull request for an rustc pull update already exists
4549
# If it does, the previous push has just updated it
4650
# If not, we create it now
4751
RESULT=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | length' --json title`
4852
if [[ "$RESULT" -eq 0 ]]; then
4953
echo "Creating new pull request"
50-
gh pr create -B master --title 'Rustc pull update' --body 'Latest update from rustc.'
54+
PR_URL=gh pr create -B master --title 'Rustc pull update' --body 'Latest update from rustc.'
55+
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
5156
else
52-
echo "Updated existing pull request"
57+
PR_URL=gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | .[0].url' --json url,title
58+
echo "pr_url=${PR_URL" >> $GITHUB_OUTPUT
5359
fi
5460
env:
5561
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
send-zulip-message:
63+
needs: [pull]
64+
if: ${{ !cancelled() }}
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Compute message
68+
id: message
69+
run: |
70+
if [ "${{ needs.pull.result }}" == "failure" ];
71+
then
72+
WORKFLOW_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
73+
echo "message=Rustc pull sync failed. Check out the [workflow URL]($WORKFLOW_URL)." >> $GITHUB_OUTPUT
74+
else
75+
echo "message=Rustc pull sync succeeded. Check out the [PR](${{ needs.pull.outputs.pr_url }})." >> $GITHUB_OUTPUT
76+
fi
77+
- name: Send a Zulip message about updated PR
78+
uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5
79+
with:
80+
api-key: ${{ secrets.ZULIP_API_TOKEN }}
81+
82+
organization-url: "https://rust-lang.zulipchat.com"
83+
to: 196385
84+
type: "stream"
85+
topic: "Subtree sync automation"
86+
content: ${{ steps.message.outputs.message }}

0 commit comments

Comments
 (0)