name: Rust Version
on:
workflow_dispatch:
schedule:
- cron: '0 13 * * *'
jobs:
check-and-update-rust-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update
- run: cargo install --locked --version 0.2.0 cargo-set-rust-version
- run: cargo set-rust-version
- id: diff
run: |
if ! git diff --exit-code; then
echo "::set-output name=update::true"
fi
- if: steps.diff.outputs.update == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b update-rust-version
git add .
git commit -m 'Update rust-version'
git push origin update-rust-version
- if: steps.diff.outputs.update == 'true'
name: Create Pull Request
uses: actions/github-script@v6
with:
script: |
await github.rest.pulls.create({
title: 'Update rust-version',
owner: context.repo.owner,
repo: context.repo.repo,
head: 'update-rust-version',
base: 'main',
body: '### What\nUpdate rust-version to latest stable.\n\n### Why\nTracking latest stable which receives security updates.'
});