|
| 1 | +name: Update rust version |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: "0 0 15 * *" # At 00:00 on day-of-month 15. |
| 5 | + workflow_dispatch: # allows manual triggering |
| 6 | +jobs: |
| 7 | + format: |
| 8 | + name: Update rustc |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + - uses: dtolnay/rust-toolchain@stable |
| 13 | + - name: Update rust-version to use latest stable |
| 14 | + run: | |
| 15 | + set -x |
| 16 | + # Extract the version from whatever version of the compiler dtolnay/rust-toolchain gives us. |
| 17 | + RUST_VERSION=$(rustc --verbose --version | sed -ne 's/^release: //p') |
| 18 | + # Update the version in the reference file. |
| 19 | + echo "${RUST_VERSION}" > rust-version |
| 20 | + echo "rust_version=${RUST_VERSION}" >> $GITHUB_ENV |
| 21 | + # In case of no new version don't make an empty PR. |
| 22 | + if ! git diff --exit-code > /dev/null; then |
| 23 | + echo "Updated rustc. Opening PR." |
| 24 | + echo "changes_made=true" >> $GITHUB_ENV |
| 25 | + else |
| 26 | + echo "Attempted to update rustc but the latest stable date did not change. Not opening any PR." |
| 27 | + echo "changes_made=false" >> $GITHUB_ENV |
| 28 | + fi |
| 29 | + - name: Create Pull Request |
| 30 | + if: env.changes_made == 'true' |
| 31 | + uses: peter-evans/create-pull-request@v6 |
| 32 | + with: |
| 33 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + author: Update Rustc Bot <[email protected]> |
| 35 | + committer: Update Rustc Bot <[email protected]> |
| 36 | + branch: create-pull-request/update-rust-version |
| 37 | + title: | |
| 38 | + ci: automated update to rustc ${{ env.rust_version }} |
| 39 | + commit-message: | |
| 40 | + ci: automated update to rustc ${{ env.rust_version }} |
| 41 | + body: | |
| 42 | + Automated update to Github CI workflow `cont_integration.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action |
0 commit comments