name: "upload artifact" description: "upload file with webdav" inputs: WEBDAV_USERNAME: required: true description: "webdav username" WEBDAV_PASSWORD: required: true description: "webdav password" ARTIFACT_TYPE: required: true description: "file build type" ARTIFACT_PLATFORM: required: true description: "file platform" ARTIFACT_NAME: required: true description: "file name" runs: using: "composite" steps: - uses: actions/setup-python@v2 with: python-version: '3.9' - name: Install Webdav 4 shell: bash run: | pip install webdav4 - name: Update release shell: python run: | import re from webdav4.client import Client client = Client( "http://mc.yuhao7370.top:5212/dav", auth=("${{ inputs.WEBDAV_USERNAME }}", "${{ inputs.WEBDAV_PASSWORD }}"), timeout=None, ) if '${{ inputs.ARTIFACT_TYPE }}' == 'release': print('Removing previous ${{ inputs.ARTIFACT_PLATFORM }} release file...') for file in client.ls('Techmino distribution'): if re.search(r'(Techmino_a[0-9]+\.[0-9]+\.[0-9]_${{ inputs.ARTIFACT_PLATFORM }}.*)', file['name']): client.remove(file['name']) print('Uploading new ${{ inputs.ARTIFACT_PLATFORM }} release file...') client.upload_file("${{ inputs.ARTIFACT_NAME }}", 'Techmino distribution/${{ inputs.ARTIFACT_NAME }}') if '${{ inputs.ARTIFACT_TYPE }}' == 'test': print('Removing previous ${{ inputs.ARTIFACT_PLATFORM }} test file...') for file in client.ls('Techmino Snapshot'): if re.search(r'(Techmino_pre[0-9]+\.[0-9]+\.[0-9]_[0-9a-z]{7}_${{ inputs.ARTIFACT_PLATFORM }}.*)', file['name']): client.remove(file['name']) print('Uploading new ${{ inputs.ARTIFACT_PLATFORM }} test file...') client.upload_file("${{ inputs.ARTIFACT_NAME }}", 'Techmino Snapshot/${{ inputs.ARTIFACT_NAME }}')