Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include comparison URLs in PR body #81

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ inputs:
{{ env.GIT_COMMIT_MESSAGE }}
```

{{ env.GIT_COMMIT_MESSAGE_2 }}

### Running GitHub Actions on this PR

GitHub Actions will not run workflows on pull requests which are opened by a GitHub Action.
Expand Down Expand Up @@ -154,6 +156,9 @@ runs:
TARGETS: ${{ inputs.inputs }}
COMMIT_MSG: ${{ inputs.commit-msg }}
PATH_TO_FLAKE_DIR: ${{ inputs.path-to-flake-dir }}
- name: Compare flake.lock files
run: $GITHUB_ACTION_PATH/compare-flake-lock.sh | tee urls.txt
shell: bash
- name: Save PR Body as file
uses: DamianReeves/[email protected]
with:
Expand All @@ -169,6 +174,11 @@ runs:
echo "$COMMIT_MESSAGE" >> $GITHUB_ENV
echo "$DELIMITER" >> $GITHUB_ENV
echo "GIT_COMMIT_MESSAGE is: ${COMMIT_MESSAGE}"
COMMIT_MESSAGE_2="$(cat urls.txt)"
echo "GIT_COMMIT_MESSAGE_2<<$DELIMITER" >> $GITHUB_ENV
echo "$COMMIT_MESSAGE_2" >> $GITHUB_ENV
echo "$DELIMITER" >> $GITHUB_ENV
echo "GIT_COMMIT_MESSAGE_2 is: ${COMMIT_MESSAGE_2}"
- name: Interpolate PR Body
uses: pedrolamas/[email protected]
with:
Expand All @@ -184,7 +194,7 @@ runs:
# action commits all new and modified files).
- name: Remove PR body template files
shell: bash
run: rm -f pr_body.txt pr_body.template
run: rm -f pr_body.txt pr_body.template urls.txt
- name: Create PR
id: create-pr
uses: peter-evans/create-pull-request@v4
Expand Down
26 changes: 26 additions & 0 deletions compare-flake-lock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail

git checkout HEAD~1 &>/dev/null
nodes1="$(nix flake metadata '.#' --json | jq '.locks.nodes')"
git checkout - &>/dev/null
nodes2="$(nix flake metadata '.#' --json | jq '.locks.nodes')"
keys1="$(echo "${nodes1}" | jq 'keys | .[]')"
keys2="$(echo "${nodes2}" | jq 'keys | .[]')"

for key in ${keys2}; do
if [[ "${keys1}" != *"${key}"* ]]; then
continue
fi
owner="$(echo "${nodes1}" | jq -r ".${key}.locked.owner")"
repo="$(echo "${nodes1}" | jq -r ".${key}.locked.repo")"
type="$(echo "${nodes1}" | jq -r ".${key}.locked.type")"
rev1="$(echo "${nodes1}" | jq -r ".${key}.locked.rev")"
rev2="$(echo "${nodes2}" | jq -r ".${key}.locked.rev")"
if [[ "${rev1}" != "${rev2}" ]]; then
if [[ "${type}" == 'github' ]]; then
echo "- https://github.com/${owner}/${repo}/compare/${rev1}...${rev2}"
fi
# TODO: support gitlab and possibly other services
fi
done