scheduled-bump-cargo-lock #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: scheduled-bump-cargo-lock | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 6' # Runs every Saturday at 00:00 UTC | |
| workflow_dispatch: | |
| defaults: | |
| run: | |
| shell: bash -xe {0} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| bump-cargo-lock: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: compatible | |
| cmd: cargo upgrade | |
| - name: incompatible | |
| cmd: cargo upgrade --incompatible | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 | |
| with: | |
| fetch-depth: 1 | |
| - name: Generate Unique Branch Name | |
| id: branch-name | |
| run: echo "branch_name=bump-flake-lock-${{ matrix.name }}$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT | |
| - uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 | |
| with: | |
| github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Populate the nix store | |
| run: | | |
| nix develop --command echo | |
| - name: Bump Cargo.lock, Cargo.toml | |
| run: | | |
| nix develop --command ${{ matrix.cmd }} | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit Changes | |
| run: | | |
| git checkout -b ${{ steps.branch-name.outputs.branch_name }} | |
| git add Cargo.lock Cargo.toml | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git commit -m "chore: Bump Rust dependencies" | |
| git push origin ${{ steps.branch-name.outputs.branch_name }} | |
| OWNER=$(echo "${{ github.repository }}" | cut -d'/' -f1) | |
| REPO=$(echo "${{ github.repository }}" | cut -d'/' -f2) | |
| curl -v --fail -X POST \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| https://api.github.com/repos/$OWNER/$REPO/pulls \ | |
| -d '{ | |
| "title": "Bump Rust dependencies", | |
| "head": "'${{ steps.branch-name.outputs.branch_name }}'", | |
| "base": "main", | |
| "body": "" | |
| }' | |
| else | |
| echo "No changes to commit." | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PR_RW }} | |