From 0b64b19fdfe0a5b884a015318043ddc34184b35e Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 14 Aug 2024 14:33:54 +0200 Subject: [PATCH] Add cargo dependency update job Signed-off-by: Sascha Grunert --- .github/workflows/cargo-upgrade.yml | 76 +++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/cargo-upgrade.yml diff --git a/.github/workflows/cargo-upgrade.yml b/.github/workflows/cargo-upgrade.yml new file mode 100644 index 0000000000..460ad7948f --- /dev/null +++ b/.github/workflows/cargo-upgrade.yml @@ -0,0 +1,76 @@ +name: cargo-upgrade +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' # At 00:00 on Sunday +env: + CARGO_TERM_COLOR: always + ACTION_MSRV_TOOLCHAIN: 1.66.1 + BODY_FILE: .cargo-upgrades +jobs: + upgrade: + if: github.ref == 'refs/heads/main' && github.repository == 'containers/conmon-rs' + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: cargo-upgrade-${{ hashFiles('**/Cargo.lock') }} + - name: Select latest toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + default: true + override: true + - name: Install cargo-edit + run: cargo install cargo-edit + - name: Upgrade direct dependencies + shell: bash + run: | + set -euox pipefail + mv .cargo .tmp + printf "Update cargo dependencies:\n\n\`\`\`\n" > "$BODY_FILE" + cargo upgrade --rust-version=$ACTION_MSRV_TOOLCHAIN >> "$BODY_FILE" + echo "\`\`\`" >> "$BODY_FILE" + mv .tmp .cargo + cargo vendor .cargo-vendor + - name: Select supported toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env['ACTION_MSRV_TOOLCHAIN'] }} + default: true + override: true + - name: Upgrade indirect dependencies + shell: bash + run: | + set -euox pipefail + mv .cargo .tmp + cargo update + mv .tmp .cargo + cargo vendor .cargo-vendor + - name: Check workspace + id: create_pr + run: | + if [[ $(git diff --stat) != '' ]]; then + echo "create_pr=true" >> "$GITHUB_OUTPUT" + fi + - name: Create PR if required + uses: peter-evans/create-pull-request@v6 + if: ${{ steps.create_pr.outputs.create_pr == 'true' }} + with: + commit-message: Update cargo dependencies + title: 'Update cargo dependencies' + body-path: ${{ env['BODY_FILE'] }} + labels: kind/dependency-change, release-note-none, ok-to-test + branch: cargo-deps + delete-branch: true + signoff: true diff --git a/.gitignore b/.gitignore index 2fc85f5b36..b0be0c00a6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /result /vendor .build +.cargo-upgrades latest-*.txt /*.tar.gz .vscode