| 
10 | 10 |   pull:  | 
11 | 11 |     if: github.repository == 'rust-lang/rustc-dev-guide'  | 
12 | 12 |     runs-on: ubuntu-latest  | 
 | 13 | +    outputs:  | 
 | 14 | +      pr_url: ${{ steps.update-pr.outputs.pr_url }}  | 
13 | 15 |     permissions:  | 
14 | 16 |       contents: write  | 
15 | 17 |       pull-requests: write  | 
@@ -40,16 +42,44 @@ jobs:  | 
40 | 42 |           git switch -c $BRANCH  | 
41 | 43 |           git push -u origin $BRANCH --force  | 
42 | 44 |       - name: Create pull request  | 
 | 45 | +        id: update-pr  | 
43 | 46 |         run: |  | 
44 | 47 |           # Check if an open pull request for an rustc pull update already exists  | 
45 | 48 |           # If it does, the previous push has just updated it  | 
46 | 49 |           # If not, we create it now  | 
47 | 50 |           RESULT=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | length' --json title`  | 
48 | 51 |           if [[ "$RESULT" -eq 0 ]]; then  | 
49 | 52 |             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  | 
51 | 55 |           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  | 
53 | 58 |           fi  | 
54 | 59 |         env:  | 
55 | 60 |           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 | +          email: "rustc-dev-guide-gha-notif-bot@rust-lang.zulipchat.com"  | 
 | 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