1
0
reusable-workflows/.gitea/workflows/deployArtifactToWebserver.yaml

63 lines
2.3 KiB
YAML
Raw Normal View History

name: Deploy Artifact to Webserver
on:
workflow_call:
inputs:
artifactName:
required: true
type: string
fileName:
required: true
type: string
uploadName:
required: false
type: string
dir:
required: true
type: string
txtFileContent:
required: false
type: string
txtFileName:
required: false
type: string
2025-01-16 09:55:49 +00:00
outputs:
downloadUrl:
description: "Url to Download the file"
value: ${{ jobs.DeployToWebserver.outputs.downloadUrl }}
jobs:
DeployToWebserver:
runs-on: ubuntu-latest
2025-01-16 09:55:49 +00:00
outputs:
downloadUrl: ${{ steps.Upload.outputs.downloadUrl }}
steps:
- name: Load Artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifactName }}
path: ./
2025-01-16 09:55:49 +00:00
- id: Upload
run: |
upload_name=${{ inputs.fileName }}
if [ "${{ inputs.uploadName }}" != "" ]; then
echo "Renaming file to ${{ inputs.uploadName }}"
mv ${{ inputs.fileName }} ${{ inputs.uploadName }}
upload_name=${{ inputs.uploadName }}
fi
echo "Uploading $upload_name to ${{ vars.WEB_DEPLOY_URL }}${{ inputs.dir }}/$upload_name"
curl -H "Authorization: Bearer ${{ vars.WEB_DEPLOY_TOKEN }}" --data-binary @"$upload_name" "${{ vars.WEB_DEPLOY_URL }}${{ inputs.dir }}/$upload_name"
echo "Uploading finished $upload_name"
echo "TXT filename is '${{ inputs.txtFileName }}'"
if [ "${{ inputs.txtFileName }}" != "-" ]; then
echo "Uploading additional text file ${{ inputs.txtFileName }} to ${{ vars.WEB_DEPLOY_URL }}${{ inputs.dir }}/${{ inputs.txtFileName }}"
printf "%b" "${{ inputs.txtFileContent }}" > ${{ inputs.txtFileName }}
curl -H "Authorization: Bearer ${{ vars.WEB_DEPLOY_TOKEN }}" --data-binary @"${{ inputs.txtFileName }}" "${{ vars.WEB_DEPLOY_URL }}${{ inputs.dir }}/${{ inputs.txtFileName }}"
else
echo "No additional text file to upload."
fi
2025-01-16 11:32:15 +00:00
downloadUrl="${{ vars.WEB_DOWNLOAD_URL }}${{ inputs.dir }}/$upload_name"
2025-01-16 09:55:49 +00:00
echo "downloadUrl=$downloadUrl" >> $GITHUB_OUTPUT
echo "Deploy upload done"