-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (72 loc) · 2.61 KB
/
update-nvfetcher.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Update nvfetcher
on:
workflow_dispatch: {}
schedule:
- cron: 0 * * * *
push:
branches:
- main
paths:
- pkgs/nvfetcher.toml
jobs:
update-nvfetcher:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
- name: Set up Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@87b14cf437d03d37989d87f0fa5ce4f5dc1a330b # v8
- name: Run nvfetcher
id: run-nvfetcher
run: |
cd pkgs
nix-shell -p nvfetcher --command 'nvfetcher -l /tmp/nvfetcher-changes'
{
echo 'changes<<EOF'
cat /tmp/nvfetcher-changes
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Update vendor hashes
id: update-vendorhash
run: |
setHash () {
jq --arg app "${1}" --arg hash "${2}" '.[$app] = $hash' pkgs/_sources/vendorhash.json > tmp.json
mv tmp.json pkgs/_sources/vendorhash.json
}
declare -a APP_NAMES
while read line; do
APP_NAMES+=("${line%:*}")
done < /tmp/nvfetcher-changes
for APP_NAME in "${APP_NAMES[@]}"; do
echo "Updating vendor hash for ${APP_NAME}..."
setHash "${APP_NAME}" ""
vendorHash=$(nix build --no-link .#${APP_NAME} 2>&1 >/dev/null | grep "got:" | cut -d':' -f2 | sed 's| ||g')
if [[ -n "${vendorHash}" ]]; then
setHash "${APP_NAME}" "${vendorHash}"
echo "Updated ${APP_NAME} with vendorHash: ${vendorHash}"
fi
done
- name: Generate Token
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
- name: Create Pull Request
id: create-pull-request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7
with:
token: ${{ steps.app-token.outputs.token }}
branch: nvfetcher/deps
title: "chore(deps): Update packages managed by nvfetcher"
commit-message: "chore(deps): Update packages managed by nvfetcher"
body: |
## Changes:
${{ steps.run-nvfetcher.outputs.changes }}
add-paths: |
pkgs/**
delete-branch: true