Flake Update #25
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: Flake Update | |
on: | |
workflow_dispatch: | |
schedule: | |
# At 10:00 UTC on Friday. | |
- cron: '0 10 * * 5' | |
jobs: | |
update: | |
name: Update | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install nix | |
uses: cachix/install-nix-action@v22 | |
with: | |
github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up cachix | |
uses: cachix/cachix-action@v12 | |
with: | |
name: yamporg | |
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
- name: Checkout code | |
uses: actions/checkout@v3.5.3 | |
- name: Set up Git | |
run: | | |
git config user.name actions-user | |
git config user.email actions@github.com | |
- name: Update dependencies | |
id: commit | |
uses: actions/github-script@v6.4.1 | |
with: | |
script: | | |
async function getHead() { | |
const out = await exec.getExecOutput('git', ['rev-parse', 'HEAD']) | |
return out.stdout | |
} | |
const prevHead = await getHead() | |
const subject = 'feat: run nix flake update' | |
await exec.exec('nix', [ | |
'flake', | |
'update', | |
'--commit-lock-file', | |
'--commit-lockfile-summary', | |
subject, | |
]) | |
const nextHead = await getHead() | |
core.setOutput('prev-head', prevHead) | |
core.setOutput('next-head', nextHead) | |
if (prevHead == nextHead) { | |
return | |
} | |
const gitLog = await exec.getExecOutput('git', ['log', '-1', '--pretty=%b']) | |
const indent = ' '.repeat(4) | |
const lines = gitLog.stdout.split('\n') | |
const summary = lines.map(x => x != '' ? indent + x : x).join('\n') | |
core.setOutput('subject', subject) | |
core.setOutput('summary', summary) | |
- name: Create PR | |
if: ${{ steps.commit.outputs.prev-head != steps.commit.outputs.next-head }} | |
uses: peter-evans/create-pull-request@v5.0.2 | |
with: | |
branch: feat/run-flake-update | |
delete-branch: true | |
title: ${{ steps.commit.outputs.subject }} | |
body: | | |
${{ steps.commit.outputs.summary }} |