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

Add comment only if there are changes under certain directory #3

Closed
humitos opened this issue Jul 25, 2022 · 1 comment
Closed

Add comment only if there are changes under certain directory #3

humitos opened this issue Jul 25, 2022 · 1 comment

Comments

@humitos
Copy link
Member

humitos commented Jul 25, 2022

It would be good to detect changes under certain directories (e.g. docs/) and only update the description in that situation. Example of a potential input for the action:

file-path:
  description: "Path where to check for file modifications"
  default: "docs/"
  required: false

Note we could use github.rest.pulls.listFiles to get the files changed in the PR:

const {data: pull_files } = await github.rest.pulls.listFiles({
    owner: context.repo.owner,
    repo: context.repo.repo,
    pull_number: context.issue.number,
});

for (let file of pull_files) {
    // do something here
}
@humitos
Copy link
Member Author

humitos commented Nov 24, 2022

This can be done with a GHA option in a simpler way instead:

on:
  pull_request_target:
    types:
      - opened
    paths:
      - "docs/**"   # <-- this line

We are using this on Read the Docs at https://github.com/readthedocs/readthedocs.org/blob/main/.github/workflows/pr-preview-links.yaml#L6-L7 and it's working fine.

@humitos humitos closed this as completed Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant