Skip to content

feat: show diff in PR repo-ansible comment #0000#160

Open
Ayesh wants to merge 1 commit intolinkorb:mainfrom
Ayesh:feat/auto-run-repo-ansible-show-diff
Open

feat: show diff in PR repo-ansible comment #0000#160
Ayesh wants to merge 1 commit intolinkorb:mainfrom
Ayesh:feat/auto-run-repo-ansible-show-diff

Conversation

@Ayesh
Copy link
Copy Markdown
Member

@Ayesh Ayesh commented Mar 31, 2026

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.

Checklist

  • Breaking change: fix or feature that would cause existing functionality to not work as expected
  • I have read the Contributing doc
  • I have read the Creating and reviewing pull requests at LinkORB guide doc
  • Lint and unit tests pass locally with my changes
  • I have added/updated necessary documentation in the README.md or doc/ directories (if appropriate)

`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.
@github-actions github-actions bot added the feat non-breaking change which adds new functionality label Mar 31, 2026
@Ayesh
Copy link
Copy Markdown
Member Author

Ayesh commented Mar 31, 2026

The following comment is a simulation of what the bot would add:

@Ayesh
Copy link
Copy Markdown
Member Author

Ayesh commented Mar 31, 2026

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 changes
diff --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>
           `
           })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat non-breaking change which adds new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant