Update flake inputs & Cargo dependencies #126
This file contains 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: 'Update flake inputs & Cargo dependencies' | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 2 * * 0' | |
env: | |
NIX_CONFIG: 'access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}' | |
jobs: | |
update-deps: | |
runs-on: [ ubuntu-latest ] | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: 'Install Nix' | |
uses: cachix/install-nix-action@v25 | |
- name: 'Get user data of token' | |
uses: actions/github-script@v7 | |
id: pat-user | |
with: | |
github-token: ${{ secrets.PR }} | |
script: | | |
const { data } = await github.request("/user"); | |
if (data.email == null) { | |
data.email = `${data.id}+${data.login}@users.noreply.github.com`; | |
} | |
if (data.name == null) { | |
data.name = data.login; | |
} | |
core.exportVariable('GIT_USER_NAME', data.name); | |
core.exportVariable('GIT_USER_EMAIL', data.email); | |
return data | |
- name: 'Configure Git with PR user' | |
run: | | |
git config user.name "$GIT_USER_NAME" | |
git config user.email "$GIT_USER_EMAIL" | |
- name: 'Update flake inputs and commit' | |
run: | | |
nix flake update --commit-lock-file | |
- name: 'Install workflow step dependencies' | |
uses: yaxitech/nix-install-pkgs-action@v3 | |
with: | |
packages: gnused | |
- name: 'Get flake metadata' | |
uses: actions/github-script@v7 | |
id: flake-metadata | |
with: | |
result-encoding: string | |
script: | | |
const res = await exec.getExecOutput('nix', [ 'flake', 'metadata' ]) | |
.then((resRaw) => { | |
// The sed expression strips any control sequences (e.g., the bold text elements) | |
return exec.getExecOutput( | |
'sed', | |
[ '-E', 's/[[:cntrl:]]\[[0-9]{1,3}m//g' ], | |
{ input: Buffer.from(resRaw.stdout) } | |
); | |
}); | |
return res.stdout; | |
- name: 'Update Cargo dependencies and commit' | |
run: | | |
nix develop -c cargo update | |
(git diff --quiet && git diff --staged --quiet) || git commit -am 'Cargo.lock: Update' | |
- name: 'Create Pull Request' | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
branch: update-flake | |
token: ${{ secrets.PR }} | |
title: Update flake inputs | |
body: | | |
Updated Flake dependencies through `nix flake update`. | |
``` | |
${{ steps.flake-metadata.outputs.result }} | |
``` | |
Updated Cargo dependencies through `cargo update`. | |
Dependency status of `main` prior to this PR: | |
[![dependency status](https://deps.rs/repo/github/yaxitech/ragenix/status.svg) | |
](https://deps.rs/repo/github/yaxitech/ragenix) |