Skip to content

Commit 25d3ce7

Browse files
authored
ci: add weekly cargo update workflow (foundry-rs#5497)
1 parent dd125cb commit 25d3ce7

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/dependencies.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Automatically run `cargo update` periodically
2+
3+
name: Update Dependencies
4+
5+
on:
6+
schedule:
7+
# Run weekly
8+
- cron: "0 0 * * SUN"
9+
workflow_dispatch:
10+
# Needed so we can run it manually
11+
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
BRANCH: cargo-update
15+
TITLE: "chore(deps): weekly `cargo update`"
16+
BODY: |
17+
Automation to keep dependencies in `Cargo.lock` current.
18+
19+
<details><summary><strong>cargo update log</strong></summary>
20+
<p>
21+
22+
```log
23+
$cargo_update_log
24+
```
25+
26+
</p>
27+
</details>
28+
29+
jobs:
30+
update:
31+
name: Update
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v3
35+
- uses: dtolnay/rust-toolchain@nightly
36+
37+
- name: cargo update
38+
# Remove first line that always just says "Updating crates.io index"
39+
run: cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
40+
41+
- name: craft commit message and PR body
42+
id: msg
43+
run: |
44+
export cargo_update_log="$(cat cargo_update.log)"
45+
46+
echo "commit_message<<EOF" >> $GITHUB_OUTPUT
47+
printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT
48+
echo "EOF" >> $GITHUB_OUTPUT
49+
50+
echo "body<<EOF" >> $GITHUB_OUTPUT
51+
echo "$BODY" | envsubst >> $GITHUB_OUTPUT
52+
echo "EOF" >> $GITHUB_OUTPUT
53+
54+
- name: Create Pull Request
55+
uses: peter-evans/create-pull-request@v5
56+
with:
57+
add-paths: ./Cargo.lock
58+
commit-message: ${{ steps.msg.outputs.commit_message }}
59+
title: ${{ env.TITLE }}
60+
body: ${{ steps.msg.outputs.body }}
61+
branch: ${{ env.BRANCH }}

0 commit comments

Comments
 (0)