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

add cargo update dependencies workflow #773

Merged
merged 5 commits into from
Nov 6, 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
73 changes: 73 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Runs `cargo update` periodically.

name: Update Dependencies

on:
schedule:
# Run weekly
- cron: 0 0 * * MON

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: cargo-update
TITLE: "chore(deps): weekly `cargo update`"
BODY: |
Automation to keep dependencies in `Cargo.lock` current.

<details><summary><strong>cargo update log</strong></summary>
<p>

```log
$cargo_update_log
```

</p>
</details>

permissions:
checks: write
contents: write
pull-requests: write

jobs:
update:
name: Update
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly

- name: Cargo update
# Remove first line that always just says "Updating crates.io index"
run: |
cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log

- name: Craft commit message and PR body
id: msg
run: |
export cargo_update_log="$(cat cargo_update.log)"

echo "commit_message<<EOF" >> $GITHUB_OUTPUT
printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$BODY" | envsubst >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- uses: actions/create-github-app-token@v1
id: github_token
with:
app-id: ${{ secrets.KAKAROT_BOT_APP_ID }}
private-key: ${{ secrets.KAKAROT_BOT_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ steps.github_token.outputs.token }}
add-paths: ./Cargo.lock
commit-message: ${{ steps.msg.outputs.commit_message }}
title: ${{ env.TITLE }}
body: ${{ steps.msg.outputs.body }}
branch: ${{ env.BRANCH }}
Loading