name: dependencies
on:
schedule:
- cron: "24 6 * * 1"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
concurrency:
group: dependencies
cancel-in-progress: false
env:
UPD_VERSION: v0.6.2
UPD_SHA256: 47b2504ff86197ec0097d6e767b5d9ff98f6e105166b8dcdb719a5281e8c5e8c
UPD_BRANCH: deps/upd
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Install upd
run: |
set -euo pipefail
curl -fsSL -o /tmp/upd.tar.gz \
"https://github.com/rvben/upd/releases/download/${UPD_VERSION}/upd-${UPD_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
echo "${UPD_SHA256} /tmp/upd.tar.gz" | sha256sum -c -
tar -xzf /tmp/upd.tar.gz -C /tmp
sudo install -m 0755 /tmp/upd /usr/local/bin/upd
upd --version
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c
with:
toolchain: 1.96.0
components: clippy, rustfmt
- uses: taiki-e/install-action@82cd3e7658a6f96c86c0234aeeda1748937cb0a1
with:
tool: nextest
- name: Apply updates
id: upd
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
upd update ./Cargo.toml --apply --lock --max-bump minor --min-age 7d \
--no-color -o text 2>&1 | tee /tmp/upd.txt
if git diff --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Report action updates left for a human
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -uo pipefail
upd update . --dry-run --max-bump minor --min-age 7d --no-color \
-o text -l actions,pre-commit > /tmp/upd-actions.txt 2>&1 || true
{
echo "### Action and hook updates (not applied)"
echo '```'
cat /tmp/upd-actions.txt
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Check
if: steps.upd.outputs.changed == 'true'
run: make check
- name: Open or update the pull request
if: steps.upd.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git switch -c "${UPD_BRANCH}"
git add Cargo.toml Cargo.lock
git commit -m "chore(deps): weekly dependency update"
# Force-pushed so the branch stays a single rolling proposal rather
# than accumulating a commit per week.
git push --force \
"https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \
"HEAD:refs/heads/${UPD_BRANCH}"
{
echo "Weekly \`upd\` run, capped at minor bumps with a 7 day cooldown."
echo
echo '```'
cat /tmp/upd.txt
echo '```'
} > /tmp/pr-body.md
if [ -z "$(gh pr list --head "${UPD_BRANCH}" --state open --json number -q '.[].number')" ]; then
gh pr create --base main --head "${UPD_BRANCH}" \
--title "chore(deps): weekly dependency update" \
--body-file /tmp/pr-body.md
else
gh pr edit "${UPD_BRANCH}" --body-file /tmp/pr-body.md
fi
- name: Nothing to update
if: steps.upd.outputs.changed != 'true'
run: echo "No dependency updates within policy." >> "$GITHUB_STEP_SUMMARY"