Git Product home page Git Product logo

file-existence-action's Introduction

Hi there, I'm André Storhaug 👋

/ˈɑːndɹe ˈstoˑɹhaːg/

I am a PhD student 🎓 at the Norwegian University of Science and Technology (NTNU), pursuing a Doctor of Philosophy (PhD) degree in Computer Science.

📫 How to reach me:

file-existence-action's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

file-existence-action's Issues

How to search in specific folder?

- name: "Check file existence"
  uses: andstor/file-existence-action@v1
  with:
    files: "/full/path/package.json"

Like this? files: "/full/path/package.json"

Feature: use Github working directory

In GitHub Actions you can use working directory:

documentation

This is an example, how it should look like

jobs:
  a-job-name:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./apache-beam-dependency-problem

but later in the file existence check, I have to repeat the working directory for the file existence check

   - name: "Check file existence linux"
        id: check_files
        uses: andstor/[email protected]
        with:
          files: "./apache-beam-dependency-problem/build/install/apache-beam-dependency-problem/lib/beam-runners-direct-java-2.53.0.jar"
          fail: true

These examples are from here

there should be a possibility to say: use working_dir yes or no.

I would love to see the example working like this:

   - name: "Check file existence linux"
        id: check_files
        uses: andstor/[email protected]
        with:
          files: "./apache-beam-dependency-problem/build/install/apache-beam-dependency-problem/lib/beam-runners-direct-java-2.53.0.jar"
          fail: true
          working_dir: true

Readme.md should look like this:

Input variable Necessity Description Default
files Required Comma separated string with paths to files and directories to check for existence. Supports glob paterns.
ignore_case Optional Ignore if a file name has upper or lower cases. true
follow_symbolic_links Optional Indicates whether to follow symbolic links. true
fail Optional Makes the Action fail on missing files. false
working_dir Optional Uses the github working directory. false

It would make sense to have the working_dir set as a standard to true but this would let all existing file checks fail, that's why I would set it default to false.

I was trying to look if I could implement it myself, but I was missing the skills to do it in TypeScript

this could also maybe closes issue #150

Only works once per workflow

I tried using this in two different jobs inside the same workflow. It only works for the first instance after that it would skip the step with
if: steps.check_file.outputs.files_exists == 'true'

I can't get directory detection to work at all

  check-runtime:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ${{ inputs.project_dir }}/
    outputs:
      files_exists: ${{ steps.check-dir.outputs.files_exists }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Check file existence
        id: check-dir
        uses: andstor/file-existence-action@v3
        with:
          files: ./runtime/*, ./runtime, runtime/, runtime, runtime/**/*, runtime/environment.yml

      - run: ls -1

Run andstor/file-existence-action@v3

  with:
    files: ./runtime/*, ./runtime, runtime/, runtime, runtime/**/*, runtime/environment.yml
    ignore_case: false
    follow_symbolic_links: true
    fail: false
These files don't exist: ./runtime/*, runtime/**/*, ./runtime, runtime/, runtime, runtime/environment.yml

Run ls -1

environment.yml
infrastructure
requirements-local.txt
runtime

Feature Request: check if file exists, ignore Upper/Lowercase

I have a little feature request: is it possible to add a boolean flag, to check if the file exists, but you can ignore upper/lowercase on it?

Because I have an automatic downloader and test, but sometimes people name the files wrong, so they mess-up with upper- or lower case... but the file is there, that's enough for me.

Is there a possibility to implement this as an optional?

*All* files must match pattern (instead of *any*)

Lets say my repo looks like this:

my_repo
│
├ sub_repo1
│   ├ README.md
│   └ other files...
│
└ sub_repo2
    └ other files...

I want to enforce a rule where all sub-repos will contain a top-level README.md file, otherwise failure. If I use the glob pattern like so:

with:
    files: "*/AUTHORS.txt"
    fails: true

it won't work because the file sub_repo1/README.md satisfies the rule. How can I make it so that the file must exist in ALL subrepos?

Calculated filenames are not found.

At the moment I'm using in my project the file-existence-action to check if some files are available.

I download some files.
I'm assuming that the file 93.pdf is there
but, as I want to have the complete test dynamical, I read the number from a file...

bash-linux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - uses: pCYSl5EDgo/cat@master
        id: read_recent
        with:
          path: issues.txt
          trim: true
      - run: echo $TEXT
        env:
          TEXT: ${{ steps.read_recent.outputs.text }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - uses: actions/[email protected]
      - name: Download Issues with start and end limit
        id: normalIssuesWithRange
        run: bash ./linux_mac/magpi-issue-downloader.sh -f $((${{steps.read_recent.outputs.text}}-6)) -l $((${{steps.read_recent.outputs.text}}-5))
.
.
.
     - name: "Check file existence Linux"
        id: check_files
        uses: andstor/file-existence-action@v1
        with:
          files: "issues/MagPi$((${{steps.read_recent.outputs.text}}-5)).pdf"
          allow_failure: false
      - name: lslah
        run: ls -lah  issues
      - name: File exists
        if: steps.check_files.outputs.files_exists == 'false'
        run: exit 1

The download itself works, as I can see in the lslah

The problem is, that the file existence check is looking for:
These files doesn't exist: issues/MagPi$((98-5)).pdf
see here

I guess it has something todo with this fs.access problem @elizabrock was also writing!
as @elizabrock wrote: it "checks for the literal existence of the string that is passed in."

Is there any way to solve this by calculate it in the action?

Security Vulnerabilities in latest version

Hi André,

I really want to use this very useful action, however, when I was going through our internal security assessment, Dependabot reported 4 vulnerabilities, one of which is High Severity. There is an available patch version for all of them though.

Dependabot also raised 10 PRs for build dependencies.

See screen shots below.

Any chance you could bump these package to remediate the vulnerabilities please ?

Kind regards

Fraser.

dependabot_alerts
dependabot_alert_HIGH
dependabot_alert_MOD_DoS_2
dependabot_alert_MOD_DoS_3
dependabot_alert_MOD_DoS_4
dependabot_prs

`allow_failure` is poorly named

I would expect if allow_failure is false... it would not be allowed to fail finding the files. This is currently not the case... if allow_failure is false, the step will succeed if the files are not found.

Alternatively if I set allow_failure to true... it fails the step if the files don't exist. That's not allowing a failure.

Allowing failure does not work

The following configuration makes the test fail, if I set the parameter allow_failure to true and the file storage/logs/laravel.log does not exist.

- name: Check for log file existence
  id: check_files
  uses: andstor/file-existence-action@v1
  with:
    files: "storage/logs/laravel.log"
    allow_failure: true
- name: Archive laravel log file
  uses: actions/upload-artifact@v1
  if: steps.check_files.outputs.files_exists == 'true'
  with:
    name: laravel-log
    path: storage/logs/laravel.log

Node.js 16 actions are deprecated

@andstor GitHub actions is planning to deprecate Node 16. The file existence action is still using Node 16. We are getting this warning that the file exists action should be updated to Node 20

Node.js 16 actions are deprecated. 
Please update the following actions to use Node.js 20: andstor/file-existence-action@v2. 
For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

Is this action maintained? Are you planning to update it?

Comma Separated List of Directories Isn't Working

      - name: Check For Files To Add
        id: check_additions
        uses: andstor/[email protected]
        with:
          files: "changed-sources/force-app, changed-sources/custom-metadata"

I keep getting log message These files don't exist: changed-sources/force-app and then when I check in another action step if: steps.check_additions.outputs.files_exists == 'true' value is apparently false even though the second directory changed-sources/custom-metadata does include files.

Workaround is running action twice and adding an or (||): steps.check_force_additions.outputs.files_exists == 'true' || steps.check_metadata_additions.outputs.files_exists == 'true'

Says here it should work: https://github.com/andstor/file-existence-action/blob/main/README.md?plain=1#L26

Unable to check existence using glob

Unable to check for files existence using the glob character (*).

Steps to reproduce

Use the following job in your github workflow.

...

jobs:
  my_job_id:
    runs-on: ubuntu-latest
    steps:
      - name: Add foo package
        run: mkdir -p package/foo/ && touch package/foo/package.json
      - name: Add bar package
        run: mkdir -p package/bar/ && touch package/bar/package.json
      - name: Check if files exist
        uses: andstor/file-existence-action@v1
        id: check_files
        with:
          files: "packages/*/package.json"
      - name: Result
        if: steps.check_files.outputs.files_exists == 'true'
        run: echo "Files exist"

Expected output:

Files exist

Actual output:

These files doesn't exist: packages/*/package.json

Feature Request: any file mode

Hi,

I'd like to propose a feature. To add a any == false flag to the action. If set to true, the action will return true, if any of the listed globs matches, as opposed to the default setting where all files must exist.

This feature will greatly simplify a common case, where we'd like to check the existence of any of the listed files:

- id: golang-sources
  uses: andstor/file-existence-action@v2
  with:
    files: go.mod, go.work
    any: true

- name: Build Go sources
  if: ${{ steps.golang-sources.outputs.files_exists == 'true' }}
  run: |
    go build ./...

instead of:

- id: gomod
  uses: andstor/file-existence-action@v2
  with:
    files: go.mod

- id: gowork
  uses: andstor/file-existence-action@v2
  with:
    files: go.work

- name: Build Go sources
  if: ${{ steps.gomod.outputs.files_exists == 'true' || steps.gowork.outputs.files_exists == 'true' }}
  run: |
    go build ./...

Update to Node 16

For self-hosted runners on ARM64 (Mac M1) only Node 16 is supported. Would be great if the action could be updated.
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.