Skip to content

Commit 276ad2c

Browse files
committed
ci: add automated flake update
1 parent 7bfbf48 commit 276ad2c

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/flake-update.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright lowRISC contributors.
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Flake Update
6+
on:
7+
workflow_dispatch:
8+
schedule:
9+
- cron: "0 0 * * SUN"
10+
11+
permissions:
12+
id-token: write
13+
contents: write
14+
15+
jobs:
16+
update_flake:
17+
name: Flake update
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
- name: Install Nix
23+
uses: cachix/install-nix-action@v31
24+
25+
- name: Flake update
26+
run: |
27+
nix flake update
28+
- name: Flake private input update
29+
working-directory: private
30+
run: |
31+
nix flake update
32+
33+
- name: Obtain token to create PR
34+
id: pr_token
35+
run: |
36+
# Obtain OIDC token from GitHub
37+
ID_TOKEN=$(curl -sSf -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://ca.lowrisc.org" | jq -r .value)
38+
echo "::add-mask::$ID_TOKEN"
39+
# Exchange for a token to create PR
40+
PR_TOKEN=$(curl -sSf -X POST -H "Authorization: Bearer $ID_TOKEN" "https://ca.lowrisc.org/api/github/repos/${{ github.repository }}/token")
41+
echo "::add-mask::$PR_TOKEN"
42+
echo "pr_token=$PR_TOKEN" >> "$GITHUB_OUTPUT"
43+
- name: Push changes
44+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7
45+
with:
46+
# Creating branch using the GitHub Actions token; the PR token doesn't have `contents: write` permission.
47+
branch-token: ${{ github.token }}
48+
branch: flake-update
49+
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
50+
commit-message: "chore: nix flake update"
51+
# Create a PR with PR token so it can trigger GitHub actions.
52+
token: ${{ steps.pr_token.outputs.pr_token }}
53+
title: "chore: nix flake update"
54+
body: "Automated update to nix flake inputs"

0 commit comments

Comments
 (0)