Skip to content

Commit

Permalink
Merge pull request #114 from ngi-nix/nix-flake-show-pr-comment
Browse files Browse the repository at this point in the history
ci: nix flake show comment in prs
  • Loading branch information
mightyiam authored Dec 5, 2023
2 parents 4418fb1 + ff02769 commit fd63db6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,26 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main
with:
upstream-cache: https://ngi.cachix.org/
- id: flake-show-diff
name: Obtain `nix flake show` output
run: |
shopt -s expand_aliases
alias show="nix flake show --all-systems"
alias filter="nix run nixpkgs#ansifilter | tail -n +2"
alias short="git rev-parse --short"
git fetch origin ${GITHUB_BASE_REF}:${GITHUB_BASE_REF}
if diff -U 1024 \
--label "$(short $GITHUB_BASE_REF) $GITHUB_BASE_REF" <(show ".?rev=$(git rev-parse ${GITHUB_BASE_REF})" | filter) \
--label "$(short HEAD) $GITHUB_HEAD_REF" <(show | filter) \
>> diff
then
echo 'output=No difference in `nix flake show`.' >> "$GITHUB_OUTPUT"
else
echo -e 'output<<EOF\n<details><summary>Difference in <code>nix flake show</code>.</summary>\n\n```diff' >> "$GITHUB_OUTPUT"
cat diff >> "$GITHUB_OUTPUT"
echo -e '```\n</details>\nEOF' >> "$GITHUB_OUTPUT"
fi
- uses: thollander/actions-comment-pull-request@v2
with:
message: ${{ steps.flake-show-diff.outputs.output }}
- run: nix ${{ runner.debug && '--debug --print-build-logs' }} flake check

0 comments on commit fd63db6

Please sign in to comment.