Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STR-676: sets a CI autoupdate cron job #550

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
storopoli marked this conversation as resolved.
Show resolved Hide resolved
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 -xe

# 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
Loading