Home > Back-end >  Upload file with GitHub action instead of folder
Upload file with GitHub action instead of folder

Time:12-21

I use actions/upload-artifact to upload artifacts after a successful workflow run like this:

   path: |
     path/to/firstbin.app
     path/to/secondbin.dmg

The binaries are stored in bundle/app/firstbin.app and bundle/dmg/secondbin.dmg. GHA uploads the bundle folder. So I get a useless folder in the artifact file. How to upload only these two files?

CodePudding user response:

The documentation clearly states that "if multiple paths are provided as input, the least common ancestor of all the search paths will be used as the root directory of the artifact." Therefore, you need to either avoid specifying multiple paths or copy the files to a flattened staging directory.

You can upload two files to the same artifact like this:

      - uses: actions/upload-artifact@v3
        with:
         name: first/abc/firstbin.app
         path: 
         if-no-files-found: error
      - uses: actions/upload-artifact@v3
        with:
         name: second/xyz/firstbin.dmg
         path: 
         if-no-files-found: error

Be careful when uploading to the same artifact and read the relevant documentation.

  • Related