bacongobbler / azure-blob-storage-upload

Uploads assets to Azure Blob Storage
Other
56 stars 25 forks source link

Upload to specific folder #12

Closed mruknowme closed 3 years ago

mruknowme commented 3 years ago

Is it possible to upload to a specific folder on the blob and clean the folder before upload?

Thanks

bacongobbler commented 3 years ago

You can provide the —destination-path flag as part of the extra_flags field. Enabling the sync flag will purge the entire container which might not be what you’re looking for, but is one option.

if you’re referring to the source directory, you can use the —pattern flag to filter certain files or file extensions.

Let me know what you come up with.

mruknowme commented 3 years ago

Perfect, thanks, will try in a moment and let you know here :)

mruknowme commented 3 years ago

@bacongobbler sorry if it's a dumb question.. I added this line to my yml file extra_flags: --destination-path test but after completing the job it still seem to upload to root directory.

According to guide, from what I understand, just specifying folder name should work: https://docs.microsoft.com/en-us/cli/azure/ext/storage-preview/storage/blob/directory?view=azure-cli-latest

Do you know what could be the issue?

Thanks

bacongobbler commented 3 years ago

Can you share an example or a link to your workflow YAML?

mruknowme commented 3 years ago
name: Upload To Azure Blob Storage
on:
  push:
    branches:
      - master
jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '15'
      - run: npm install
      - run: npm run build
      - uses: bacongobbler/azure-blob-storage-upload@v1.1.1
        with:
          source_dir: 'dist'
          container_name: '$web'
          connection_string: ${{ secrets.ConnectionString }}
          sync: true
          extra_flags: --destination-path test
bacongobbler commented 3 years ago

Try wrapping the arguments in double quotes. I have a working example here that you can reference against: https://github.com/fishworks/gofish/blob/main/.github/workflows/build.yml#L84

mruknowme commented 3 years ago

Ah, yep, not only I missed quotes but for some reason I used extra_flags instead of extra_args all working well now, thank you!

bacongobbler commented 3 years ago

Ah, that’s my fault. I referenced it as extra_flags in my first comment. Apologies.

Glad you found a solution! Happy holidays