@@ -22,22 +22,28 @@ jobs:
22
22
current_toolchain_epoch=$(date --date $current_toolchain_date +%s)
23
23
next_toolchain_date=$(date --date "@$(($current_toolchain_epoch + 86400))" +%Y-%m-%d)
24
24
echo "next_toolchain_date=$next_toolchain_date" >> $GITHUB_ENV
25
- sed -i "/^channel/ s/$current_toolchain_date/$next_toolchain_date/" rust-toolchain.toml
26
- git diff
27
- git clone --filter=tree:0 https://github.com/rust-lang/rust rust.git
28
- cd rust.git
29
- current_toolchain_hash=$(curl https://static.rust-lang.org/dist/$current_toolchain_date/channel-rust-nightly-git-commit-hash.txt)
30
- echo "current_toolchain_hash=$current_toolchain_hash" >> $GITHUB_ENV
31
- next_toolchain_hash=$(curl https://static.rust-lang.org/dist/$next_toolchain_date/channel-rust-nightly-git-commit-hash.txt)
32
- echo "next_toolchain_hash=$next_toolchain_hash" >> $GITHUB_ENV
33
- EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
34
- echo "git_log<<$EOF" >> $GITHUB_ENV
35
- git log --oneline $current_toolchain_hash..$next_toolchain_hash | \
36
- sed 's#^#https://github.com/rust-lang/rust/commit/#' >> $GITHUB_ENV
37
- echo "$EOF" >> $GITHUB_ENV
38
- cd ..
39
- rm -rf rust.git
25
+ if ! git ls-remote --exit-code origin toolchain-$next_toolchain_date ; then
26
+ echo "branch_exists=false" >> $GITHUB_ENV
27
+ sed -i "/^channel/ s/$current_toolchain_date/$next_toolchain_date/" rust-toolchain.toml
28
+ git diff
29
+ git clone --filter=tree:0 https://github.com/rust-lang/rust rust.git
30
+ cd rust.git
31
+ current_toolchain_hash=$(curl https://static.rust-lang.org/dist/$current_toolchain_date/channel-rust-nightly-git-commit-hash.txt)
32
+ echo "current_toolchain_hash=$current_toolchain_hash" >> $GITHUB_ENV
33
+ next_toolchain_hash=$(curl https://static.rust-lang.org/dist/$next_toolchain_date/channel-rust-nightly-git-commit-hash.txt)
34
+ echo "next_toolchain_hash=$next_toolchain_hash" >> $GITHUB_ENV
35
+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
36
+ echo "git_log<<$EOF" >> $GITHUB_ENV
37
+ git log --oneline $current_toolchain_hash..$next_toolchain_hash | \
38
+ sed 's#^#https://github.com/rust-lang/rust/commit/#' >> $GITHUB_ENV
39
+ echo "$EOF" >> $GITHUB_ENV
40
+ cd ..
41
+ rm -rf rust.git
42
+ else
43
+ echo "branch_exists=true" >> $GITHUB_ENV
44
+ fi
40
45
- name : Create Pull Request
46
+ if : ${{ ! env.branch_exists }}
41
47
uses : peter-evans/create-pull-request@v4
42
48
with :
43
49
commit-message : Upgrade Rust toolchain to nightly-${{ env.next_toolchain_date }}
0 commit comments