Unable to find any artifacts for the associated workflow - github actions

51 Views Asked by At

I have two jobs of the same github workflow. The first job produces an artifact and uploads it. Here is the log for that:

Run actions/upload-artifact@v4
With the provided path, there will be 58 files uploaded
Artifact name is valid!
Root directory input is valid!
Beginning upload of artifact content to blob storage
Uploaded bytes 6049904
Finished uploading artifact content to blob storage!
SHA256 hash of uploaded artifact zip is 234760fcd4148780c7f4cbb3a0296eca3a3c5ae0d54457fbd5d2f97c7411d00a
Finalizing artifact upload
Artifact DIS_1.0.5.zip successfully finalized. Artifact ID 1366404513
Artifact DIS_1.0.5 has been successfully uploaded! Final size is 6049904 bytes. Artifact ID is 1366404513
Artifact download URL: https://github.com/my-company-url/DIS.API/actions/runs/8466719969/artifacts/1366404513

The second job, for some reason cannot find the artifact, even when I intentially remove the name, which should be forcing the step to download all artifacts. Here is the log for the second job:

Run actions/download-artifact@v3
No artifact name specified, downloading all artifacts
Creating an extra directory for each artifact that is being downloaded
Unable to find any artifacts for the associated workflow
There were 0 artifacts downloaded
Artifact download has finished successfully

Any idea what might be causing that ? Here is the whole pipeline script:

name: build-and-deploy

# todo: delete this and use the one below
on: [workflow_dispatch]

# todo: use this and delete the one above
# on:
#   push:
#     branches: ["main"]
#   pull_request:
#     branches: ["main"]

env:
  DOTNET_INSTALL_DIR: "./.dotnet"
  VERSION: 1.0.${{ github.run_number }}
  PACKAGE_STORE_NAME: Nexus # Package store name in the nuget.config file.
  PACKAGE_STORE_URI: https://nexus.milestone.dev # The URI
  PACKAGE_STORE_REPO: experimental-nuget # and repo
  BUILD_CONFIGURATION: -c Release

jobs:
  build:
    runs-on: gha-runner-scale-set-linux
    steps:
      - uses: actions/checkout@v3

      - name: Apt update
        run: sudo apt-get update

      - name: Install CURL
        run: sudo apt-get install -y curl

      - name: Setup .NET
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: 8.0.x

      - name: Update Nuget Source
        run: dotnet nuget update source nexus --username ${{secrets.NEXUS_PIPELINE_SERVICE_TOKEN_USER}} --password ${{ secrets.NEXUS_PIPELINE_SERVICE_TOKEN_PASSWORD}} --store-password-in-clear-text

      - name: Restore dependencies
        run: dotnet restore

      - name: Build
        run: dotnet build ${{ env.BUILD_CONFIGURATION }} --no-restore

      - name: Test
        run: dotnet test ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity normal 

      - name: Dotnet Publish API
        if: github.ref == 'refs/heads/main'
        run: dotnet publish ./DIS.Web/DIS.Web.csproj ${{ env.BUILD_CONFIGURATION }} --no-build -o ./publish

      - name: "Upload Artifact"
        if: github.ref == 'refs/heads/main'
        uses: actions/upload-artifact@v4
        with:
          name: DIS_${{ env.VERSION }}
          path: ./publish
          retention-days: 5
  publish-docker-image:
    runs-on: gha-runner-scale-set-linux
    needs: build
    steps:
      - name: Download Artifact
        uses: actions/download-artifact@v3
        with:
          name: DIS_${{ env.VERSION }}
      - name: List Artifact Contents
        run: ls -R
        
1

There are 1 best solutions below

0
GuiFalourd On BEST ANSWER

The error message isn't clear, but your issue is related to the compatibility between the actions/download-artifact and the actions/upload-artifact tags.

You need both actions to use the same version (@v3 or @v4).

Example using v4:

jobs:
  build:
    runs-on: gha-runner-scale-set-linux
    steps:
      [ ... ]
      - name: "Upload Artifact"
        if: github.ref == 'refs/heads/main'
        uses: actions/upload-artifact@v4
        with:
          name: DIS_${{ env.VERSION }}
          path: ./publish
          retention-days: 5
  
  publish-docker-image:
    runs-on: gha-runner-scale-set-linux
    needs: build
    steps:
      - name: Download Artifact
        uses: actions/download-artifact@v4 # UPDATE HERE
        with:
          name: DIS_${{ env.VERSION }}
      - name: List Artifact Contents
        run: ls -R