-
Notifications
You must be signed in to change notification settings - Fork 9
55 lines (49 loc) · 1.84 KB
/
rust-set-rust-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Rust Set Rust Version
on:
workflow_call:
jobs:
set-rust-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup update
- uses: stellar/binaries@v21
with:
name: cargo-set-rust-version
version: 0.5.0
# Update the rust-version in all workspace crates to the latest stable
# version.
- run: cargo set-rust-version
# Check if there is any diff resulting from updating the crates. If there is
# set the update=true output for following steps.
- id: diff
run: |
if ! git diff --exit-code; then
echo "name=update::true" >> "$GITHUB_OUTPUT"
fi
# If the diff step indicates an update is required, create a branch and push
# it to GitHub. If the branch already exists with a change the push should
# fail, and so we shouldn't end up with multiple PRs.
- 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 the diff step indicates an update is required, open a PR.
- 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.'
});