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

Possible to use this action to detect when files are deleted? #180

Closed
AndrewLane opened this issue Jun 21, 2022 · 5 comments · Fixed by #181
Closed

Possible to use this action to detect when files are deleted? #180

AndrewLane opened this issue Jun 21, 2022 · 5 comments · Fixed by #181

Comments

@AndrewLane
Copy link

As far as I can tell, if the only operation that happens to the file system is that a file or files are deleted, then files_changed will return 'false'. Is that accurate? If so, any workarounds that you can think of to detect when any file changes happen (modification, addition, or deletion)?

@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project to help us reach a wider audience.

@AndrewLane
Copy link
Author

If it helps, my use case for this action is to supplement other parts of my workflow that are generating documentation markdown files. In the case where some documentation no longer applies and needs to be deleted, I'm looking to use automation to detect when this file is deleted by a script further up the chain.

@jackton1
Copy link
Member

As far as I can tell, if the only operation that happens to the file system is that a file or files are deleted, then files_changed will return 'false'. Is that accurate? If so, any workarounds that you can think of to detect when any file changes happen (modification, addition, or deletion)?

That’s correct and this seems like a valid use case, I’ve added support for detecting deleted files, it should be available in the latest release.

@AndrewLane
Copy link
Author

Great, thanks for the quick turnaround!

@shinebayar-g
Copy link

shinebayar-g commented Sep 28, 2023

Does this still work? @jackton1

name: Build

on:
  push:

jobs:
  build:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3

      - run: |
          rm README.md
          echo "new file" > new-file.txt

      - name: Check changed files
        id: changed-files
        uses: tj-actions/verify-changed-files@v16

      - name: Print changed files
        run: |
          for file in ${{ steps.changed-files.outputs.changed_files }}; do
            echo "file: $file"
            echo "------"
          done

      - run: git status

It's not detecting deleted files. But successfully detected a new file.

image

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

Successfully merging a pull request may close this issue.

3 participants