From 9e8a01779b9b285a4e41f6ac68097719e08041c6 Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Thu, 21 Dec 2023 18:50:45 +0000 Subject: [PATCH] PTFE-1257 uploading an empty directory --- .github/workflows/test-upload.yaml | 15 +++++++++++++++ src/methods.ts | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/.github/workflows/test-upload.yaml b/.github/workflows/test-upload.yaml index dfcefb4b..44daf149 100644 --- a/.github/workflows/test-upload.yaml +++ b/.github/workflows/test-upload.yaml @@ -105,3 +105,18 @@ jobs: - name: Compate files2 run: cmp --silent upload_action.yaml ./action.yaml + test-empty-folder: + runs-on: ubuntu-latest + environment: ${{ inputs.environment || 'production' }} + name: A job that try to push an empty folder + steps: + - uses: actions/checkout@v3 + - run: mkdir -p artifacts + - name: Push all files + uses: ./ + with: + url: ${{ vars.ARTIFACTS_URL }} + user: ${{ secrets.ARTIFACTS_USER }} + password: ${{ secrets.ARTIFACTS_PASSWORD }} + source: ./artifacts + method: upload diff --git a/src/methods.ts b/src/methods.ts index e9bc2a97..35343792 100644 --- a/src/methods.ts +++ b/src/methods.ts @@ -170,6 +170,11 @@ export async function upload(inputs: InputsArtifacts): Promise { requests.push(file) } + // if no files are found, log a warning and exit + if (requests.length === 0) { + core.warning(`No files found for the provided path: ${inputs.source}`) + return + } await async.eachLimit(requests, 16, async (file: string, next) => { core.info(`Uploading file: ${file}`) try {