Merge pull request 'inject file directly' (#107) from feature/artifact-update into main
Some checks failed
Check flake.lock / Check health of `flake.lock` (push) Successful in 14s
Check Nix formatting / Perform Nix format checks (push) Successful in 4m2s
Check Nix flake / Perform Nix flake checks (push) Successful in 9m42s
Update flakes / update_lockfile (push) Failing after 13m20s

Reviewed-on: #107
This commit is contained in:
ahuston-0 2025-05-27 00:20:02 -04:00
commit 3577f79936
2 changed files with 50 additions and 11 deletions

View File

@ -51,7 +51,7 @@ jobs:
id: upload-diff
uses: actions/upload-artifact@v3
with:
name: nix flake diff
name: nix-flake-diff.log
path: post-diff
compression-level: 9
if-no-files-found: error
@ -61,25 +61,33 @@ jobs:
with:
path: pr_body.template
contents: |
- The following Nix Flake inputs were updated:
- The following Nix Flake inputs were updated:
```
${{ env.UPDATE_LOG }}
```
Flake input changes:
Flake Diff can be found here:
${{ steps.upload-diff.outputs.artifact-url }}
```shell
${{ env.UPDATE_LOG }}
```
Auto-generated by [update.yml][1] with the help of
[create-pull-request][2].
Flake evaluation diff:
[1]: https://nayeonie.com/ahuston-0/nix-dotfiles/src/branch/main/.github/workflows/flake-update.yml
[2]: https://forgejo.stefka.eu/jiriks74/create-pull-request
```shell
nix-diff-placeholder
```
Auto-generated by [update.yml][1] with the help of
[create-pull-request][2].
[1]: https://nayeonie.com/ahuston-0/nix-dotfiles/src/branch/main/.github/workflows/flake-update.yml
[2]: https://forgejo.stefka.eu/jiriks74/create-pull-request
- name: Generate PR body
uses: pedrolamas/handlebars-action@v2.4.0 # v2.4.0
with:
files: "pr_body.template"
output-filename: "pr_body.md"
- name: template diff into PR body
run: |
nix utils/inject-diff.py
- name: Save PR body
id: pr_body
uses: juliangruber/read-file-action@v1

31
utils/inject-diff.py Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env nix
#! nix shell nixpkgs#python3 --command python
import logging
def inject_diff():
source_file = 'post-diff'
target_file = 'pr_body.md'
placeholder = "nix-diff-placeholder"
logging.info(f"injecting '{source_file}' into '{target_file}' using '{placeholder}' as a placeholder")
out = []
with open(source_file,'r') as src:
src_content = src.read()
with open(target_file,'r') as tgt:
for line in tgt.readlines():
if placeholder in line:
out.append(line.replace(placeholder,src_content))
else:
out.append(line)
logging.info(out)
with open(target_file,'w') as tgt:
tgt.writelines(out)
if __name__ == "__main__":
logging.basicConfig( level=logging.INFO)
inject_diff()