LanceMcCarthy / Action-AzureBlobUpload

A GitHub action to upload files to Azure Blob storage, compatible with all Actions runner operating systems.
MIT License
15 stars 4 forks source link

Question: Is it possible to rename the file on upload #420

Open LiamDHall opened 4 months ago

LiamDHall commented 4 months ago

so I have an image i want to upload but the source image will not conform to the naming requirement used by the application that in the end will be looking for.

Is it possible to rename the file on upload

LanceMcCarthy commented 4 months ago

Hi @LiamDHall

This is an interesting situation that hasn't come up yet, because usually the file is available to be renamed before the upload step.

It's as easy as this single command Rename-Item -NewName {$_.name -replace 'original', 'replacement'}, so you can put it directly before the upoad step.

Tor example, let's say I want to replace - with an _ in all my .png file names.

- name: Change filename dashes to underscores
  run: |
    Get-ChildItem "/MyFolderToUpload" -Recurse -Filter "*.png" | Rename-Item -NewName {$_.name -replace '-', '_'}

- name: Uploading Files to Azure Blob
  id: sideload-blob-upload
  uses: LanceMcCarthy/Action-AzureBlobUpload@v3
  with:
    connection_string: "${{ secrets.AZURE_DVLUP_BLOB_CONNECTION_STRING }}"
    container_name: general-app-files
    source_folder: "/MyFolderToUpload"
    destination_folder: "MyUploadedStuff"
    clean_destination_folder: true
    is_recursive: true
    delete_if_exists: true

I'll see about possible adding this feature to the upload action, I'll need to be extra careful not to break anyone else in the process though.