forked from rust-lang/rustc-dev-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (94 loc) · 3.51 KB
/
rustc-pull.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: rustc-pull
on:
pull_request:
workflow_dispatch:
schedule:
# Run at 04:00 UTC every Monday
- cron: '0 4 * * 1'
jobs:
pull:
if: github.repository == 'rust-lang/rustc-dev-guide'
runs-on: ubuntu-latest
outputs:
message: ${{ steps.update-pr.outputs.message }}
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
# We need the full history for josh to work
fetch-depth: '0'
- name: Install stable Rust toolchain
run: rustup update stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: "josh-sync"
# Cache the josh directory with checked out rustc
cache-directories: "/home/runner/.cache/rustc-dev-guide-josh"
- name: Install josh
run: RUSTFLAGS="--cap-lints warn" cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r24.10.04
- name: Setup bot git name and email
run: |
git config --global user.name 'The rustc-dev-guide Cronjob Bot'
git config --global user.email '[email protected]'
- name: Perform rustc-pull
run: cargo run --manifest-path josh-sync/Cargo.toml -- rustc-pull
- name: Push changes to a branch
run: |
# Update a sticky branch that is used only for rustc pulls
BRANCH="rustc-pull"
git switch -c $BRANCH
git push -u origin $BRANCH --force
- name: Create pull request
id: update-pr
run: |
# Check if an open pull request for an rustc pull update already exists
# If it does, the previous push has just updated it
# If not, we create it now
RESULT=`gh pr list --author github-actions[bot] --state open -q 'map(select(.title=="Rustc pull update")) | length' --json title`
if [[ "$RESULT" -eq 0 ]]; then
echo "Creating new pull request"
gh pr create -B master --title 'Rustc pull update' --body 'Latest update from rustc.'
else
echo "Updated existing pull request"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
base:
runs-on: ubuntu-latest
outputs:
message: ${{ steps.update-pr.outputs.message }}
steps:
# - name: Step 1
# run: exit 1
- name: Update PR
id: update-pr
run: echo "message=M1" >> "$GITHUB_OUTPUT"
send-zulip-message:
needs: [base]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Compute message
id: message
run: |
if [ "${{ needs.base.result }}" == "failure" ];
then
MESSAGE="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
echo "message=Rustc pull sync has failed. Check out the [workflow URL]($MESSAGE)." >> $GITHUB_OUTPUT;
else
echo "message=FOO" >> $GITHUB_OUTPUT;
fi
- name: Print message
run: echo "${{ steps.message.outputs.message }}"
# - name: Send a Zulip message about updated PR
# uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5
# with:
# api-key: ${{ secrets.ZULIP_API_TOKEN }}
# email: "[email protected]"
# organization-url: "https://rust-lang.zulipchat.com"
# to: 196385
# type: "stream"
# topic: "Subtree sync automation"
# content: ${{ steps.message.outputs.message }}