0
0
reusable-workflows/.gitea/workflows/transfertWithRenameWebserver.yaml
2025-06-23 10:02:25 +02:00

49 lines
1.8 KiB
YAML

name: Transfert with rename to Webserver
on:
workflow_call:
inputs:
downloadFile:
required: true
type: string
uploadFile:
required: true
type: string
outputs:
newDownloadUrl:
description: "Url to Download the file"
value: ${{ jobs.transfer.outputs.newDownloadUrl }}
jobs:
transfer:
runs-on: ubuntu-latest
outputs:
newDownloadUrl: ${{ steps.transfer.outputs.newDownloadUrl }}
steps:
- id: transfer
run: |
downloadUrl=${{ vars.WEB_DOWNLOAD_URL }}${{ inputs.downloadFile }}
uploadUrl=${{ vars.WEB_DEPLOY_URL }}${{ inputs.uploadFile }}
newDownloadUrl=${{ vars.WEB_DOWNLOAD_URL }}${{ inputs.uploadFile }}
# Extract file names from the input paths
downloadFileName=$(basename "${{ inputs.downloadFile }}")
uploadFileName=$(basename "${{ inputs.uploadFile }}")
echo "Download URL: $downloadUrl"
curl -O -R $downloadUrl
# Get the file creation date and save it into a variable
fileCreatedDate=for %F in ("BridgeSetupAbc.exe") do @for /f "tokens=1-3 delims=. " %a in ("%~tF") do @for /f "tokens=2 delims= " %t in ("%~tF") do @echo %c-%b-%aT%t:00
echo "File created date: $fileCreatedDate"
if [ "$downloadFileName" != "$uploadFileName" ]; then
echo "Renaming file to $uploadFileName"
mv "$downloadFileName" "$uploadFileName"
else
echo "No renaming needed"
fi
echo "Upload URL: $uploadUrl"
curl -H "Authorization: Bearer ${{ vars.WEB_DEPLOY_TOKEN }}" -H "X-Upload-Mtime: $fileCreatedDate" --data-binary @"$uploadFileName" "$uploadUrl"
echo "newDownloadUrl=$newDownloadUrl" >> $GITHUB_OUTPUT
echo "Deploy upload done"