feat: show diff in PR repo-ansible comment #0000#160
Open
Ayesh wants to merge 1 commit intolinkorb:mainfrom
Open
feat: show diff in PR repo-ansible comment #0000#160Ayesh wants to merge 1 commit intolinkorb:mainfrom
Ayesh wants to merge 1 commit intolinkorb:mainfrom
Conversation
`repo-ansible` maintains a GitHub Actions workflow that is triggered when a PR is made on the repo. It runs repo-ansible on the PR branch, and if running repo-ansible changes anything, it places a comment on the PR saying this: ``` Once PR is merged, repo-ansible will run on ... and the following changes will apply ``` followed by the repo-ansible output. The repo-ansible output shows how many files will be created, deleted, added, or modified. However, the exact changes are now shown in this comment. This PR adds that feature. After a repo-ansible run that changes any repo-ansible-managed changes, the automatic commit now includes the exact diff of the change. It is folded by default with a `See changes` section. When clicked, it opens syntax-highlighted `git diff` output. The folding keeps the comment clean, and the added diff makes the exact changes visible.
Member
Author
|
The following comment is a simulation of what the bot would add: |
Member
Author
|
Once PR is merged, repo-ansible will run on master and the following changes will apply PLAY [localhost] ***************************************************************
TASK [Generate repo-ansible workflow] ******************************************
changed: [localhost]
TASK [generate .devcontainer/docker-compose.yml] *******************************
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=44 changed=2 unreachable=0 failed=0 skipped=10 rescued=0 ignored=0 See changesdiff --git a/.github/workflows/auto-run-repo-ansible.yaml b/.github/workflows/auto-run-repo-ansible.yaml
index 8c4cccca..278cbcf6 100644
--- a/.github/workflows/auto-run-repo-ansible.yaml
+++ b/.github/workflows/auto-run-repo-ansible.yaml
@@ -49,13 +49,6 @@ jobs:
echo EOF
} >> "$GITHUB_ENV"
- export DIFF=$(git diff)
- {
- echo 'REPO_ANSIBLE_DIFF<<EOF'
- echo "$DIFF"
- echo EOF
- } >> "$GITHUB_ENV"
-
if ! echo "$OUTPUT" | grep "changed=0"; then
echo "REPOSITORY_CHANGED=1" >> "$GITHUB_ENV"
fi
@@ -79,7 +72,6 @@ jobs:
with:
script: |
const changes = process.env.REPO_ANSIBLE_OUTPUT
- const diff = process.env.REPO_ANSIBLE_DIFF
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
@@ -89,12 +81,5 @@ jobs:
\`\`\`shell
${changes}
\`\`\`
-
- <details>
- <summary>See changes</summary>
- \`\`\`diff
- ${diff}
- \`\`\`
- </details>
`
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
repo-ansiblemaintains a GitHub Actions workflow that is triggered when a PR is made on the repo. It runs repo-ansible on the PR branch, and if running repo-ansible changes anything, it places a comment on the PR saying this:followed by the repo-ansible output.
The repo-ansible output shows how many files will be created, deleted, added, or modified. However, the exact changes are now shown in this comment.
This PR adds that feature. After a repo-ansible run that changes any repo-ansible-managed changes, the automatic commit now includes the exact diff of the change.
It is folded by default with a
See changessection. When clicked, it opens syntax-highlightedgit diffoutput. The folding keeps the comment clean, and the added diff makes the exact changes visible.Checklist