63 lines
2.3 KiB
YAML
63 lines
2.3 KiB
YAML
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
|
|
outputs:
|
|
downloadUrl:
|
|
description: "Url to Download the file"
|
|
value: ${{ jobs.DeployToWebserver.outputs.downloadUrl }}
|
|
jobs:
|
|
DeployToWebserver:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
downloadUrl: ${{ steps.Upload.outputs.downloadUrl }}
|
|
steps:
|
|
- name: Load Artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: ${{ inputs.artifactName }}
|
|
path: ./
|
|
- 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
|
|
|
|
downloadUrl="${{ vars.WEB_DOWNLOAD_URL }}${{ inputs.dir }}/$upload_name"
|
|
echo "downloadUrl=$downloadUrl" >> $GITHUB_OUTPUT
|
|
echo "Deploy upload done" |