Skip to content

Commit 508ee80

Browse files
authored
Merge pull request #2216 from Kobzol/ci-pull-zulip
Send a message to Zulip when a sync finishes
2 parents 8c5b8fa + f9cb2ec commit 508ee80

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

Diff for: .github/workflows/rustc-pull.yml

+32-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,44 @@ jobs:
4042
git switch -c $BRANCH
4143
git push -u origin $BRANCH --force
4244
- name: Create pull request
45+
id: update-pr
4346
run: |
4447
# Check if an open pull request for an rustc pull update already exists
4548
# If it does, the previous push has just updated it
4649
# If not, we create it now
4750
RESULT=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | length' --json title`
4851
if [[ "$RESULT" -eq 0 ]]; then
4952
echo "Creating new pull request"
50-
gh pr create -B master --title 'Rustc pull update' --body 'Latest update from rustc.'
53+
PR_URL=gh pr create -B master --title 'Rustc pull update' --body 'Latest update from rustc.'
54+
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
5155
else
52-
echo "Updated existing pull request"
56+
PR_URL=gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | .[0].url' --json url,title
57+
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
5358
fi
5459
env:
5560
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
send-zulip-message:
62+
needs: [pull]
63+
if: ${{ !cancelled() }}
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Compute message
67+
id: message
68+
run: |
69+
if [ "${{ needs.pull.result }}" == "failure" ];
70+
then
71+
WORKFLOW_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
72+
echo "message=Rustc pull sync failed. Check out the [workflow URL]($WORKFLOW_URL)." >> $GITHUB_OUTPUT
73+
else
74+
echo "message=Rustc pull sync succeeded. Check out the [PR](${{ needs.pull.outputs.pr_url }})." >> $GITHUB_OUTPUT
75+
fi
76+
- name: Send a Zulip message about updated PR
77+
uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5
78+
with:
79+
api-key: ${{ secrets.ZULIP_API_TOKEN }}
80+
81+
organization-url: "https://rust-lang.zulipchat.com"
82+
to: 196385
83+
type: "stream"
84+
topic: "Subtree sync automation"
85+
content: ${{ steps.message.outputs.message }}

0 commit comments

Comments
 (0)