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