Skip to content

Commit

Permalink
ci: add cron update nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
storopoli committed Dec 16, 2024
1 parent e53f8f4 commit bd9769d
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/cron-nightly-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Update nightly Rust
on:
schedule:
- cron: "29 17 1 * *" # At 17:29 on day-of-month 1.
workflow_dispatch: # allows manual triggering
env:
CARGO_TERM_COLOR: always
jobs:
format:
name: Update nightly Rustc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@nightly
- name: Update rust-toolchain.toml to use latest nightly
run: |
set -x
# Get the latest nightly date.
# If the latest nightly date is not the same as the current nightly date,
# rustup will default to the latest nightly up to TODAY.
#
# Example: If the latest nightly is 2023-07-01, and the TODAY is 2023-07-02,
# then rustup will default to nightly-2023-07-01.
TODAY="$(date +%Y-%m-%d)"
# Update the nightly version in the rust-toolchain.toml file.
echo "Updating rust-toolchain.toml to use nightly-$TODAY"
sed -i "s/^channel = \"nightly-.*\"/channel = \"nightly-$TODAY\"/" rust-toolchain.toml
# Update the nightly date in the environment.
echo "nightly_date=${TODAY}" >> "$GITHUB_ENV"
# Maybe there is no new nightly.
# In this case don't make an empty PR.
if ! git diff --exit-code > /dev/null; then
echo "Updated nightly. Opening PR."
echo "changes_made=true" >> "$GITHUB_ENV"
else
echo "Attempted to update nightly but the latest-nightly date did not change. Not opening any PR."
echo "changes_made=false" >> "$GITHUB_ENV"
fi
- name: Create Pull Request
if: env.changes_made == 'true'
uses: peter-evans/create-pull-request@v7
env:
NIGHTLY_DATE: ${{ env.nightly_date }}
with:
author: Update Nightly Rustc Bot <[email protected]>
committer: Update Nightly Rustc Bot <[email protected]>
title: Automated update to rustc (to nightly-$NIGHTLY_DATE)
body: |
Automated update to Rust nightly by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action
commit-message: Automated update to Rust nightly-$NIGHTLY_DATE
branch: create-pull-request/automated-nightly-update

0 comments on commit bd9769d

Please sign in to comment.