Recently we've been seeing some failures in our Azure / GitHub Actions deployment pipelines for deleting artifacts after an artifact is built/deployed to our Azure environment, with this specific log:
Run geekyeggo/delete-artifact@v1
with:
name: net-app
failOnError: true
env:
AZURE_HTTP_USER_AGENT:
Failed to list artifacts; status code 404
Error: Failed to load artifacts; debug logs may be available.
The workflow scripts themselves have not changed in months, so I suspect something has changed on the GitHub/Azure side. When I go into a GitHub Actions workflow run in GitHub when an Artifact is still in storage, I can see it in the GitHub ui with the associated workflow run. It looks like these Artifacts haven't been deleted in quite a while automatically. I verified this by looking at previous runs prior to the error and noticed the delete-artifact job in question previously produced a log of:
Run geekyeggo/delete-artifact@v1
with:
name: net-app
failOnError: true
env:
AZURE_HTTP_USER_AGENT:
Warning: Unable to delete artifact "net-app"; the artifact was not found.
So, it seems like in some ways this script was always broken, but in other ways that things have changed since it is no longer a warning and now an error.
I'm going to include the script we use as a reference.
name: Prod - Build and deploy ASP.Net Core app to Azure Web App - Coffee
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-net-app:
runs-on: windows-latest
env:
ArtifactName: net-app-${{ github.run_number }}
steps:
- uses: actions/checkout@v2
- name: Set up Node.js v16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true
- name: Sets the environment for PROD
run: .\DeploymentScripts\Configure-Net-App-Prod.ps1
shell: powershell
- name: Build CoffeeSPA.Web
run: dotnet build --configuration Release CoffeeSPA.Web\CoffeeSPA.Web.csproj
- name: Build CoffeeSPA.Worker
run: dotnet build --configuration Release CoffeeSPA.Worker\CoffeeSPA.Worker.csproj
- name: Publish CoffeeSPA.Web
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/Web CoffeeSPA.Web\CoffeeSPA.Web.csproj
- name: Publish CoffeeSPA.Worker
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/Web/app_data/jobs/continuous/CoffeeSPA.Worker CoffeeSPA.Worker\CoffeeSPA.Worker.csproj
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: net-app
path: ${{env.DOTNET_ROOT}}/Web
deploy-net-app:
runs-on: windows-latest
needs:
- build-net-app
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: net-app
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'coffee'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }}
package: .
- name: Delete artifact
uses: geekyeggo/delete-artifact@v1
with:
name: net-app
failOnError: true
So... what exactly is the remediation here to make sure Artifacts are deleted correctly? Is it delete-artifact@v1 that's the problem? Is it the GitHub Actions workflow script above? Is it a mixture of both?
I suspect the "net-app"'s final upload destination from the Workflow script (ex: GUID/workflow-job-run-some-GUID/artifacts/some-GUID.zip) isn't being carried through the script to the delete step/job geekyeggo/delete-artifact@v1, but I'm not sure on that.
Recently we've been seeing some failures in our Azure / GitHub Actions deployment pipelines for deleting artifacts after an artifact is built/deployed to our Azure environment, with this specific log:
Run geekyeggo/delete-artifact@v1
with:
name: net-app
failOnError: true
env:
AZURE_HTTP_USER_AGENT:
Failed to list artifacts; status code 404
Error: Failed to load artifacts; debug logs may be available.
The workflow scripts themselves have not changed in months, so I suspect something has changed on the GitHub/Azure side. When I go into a GitHub Actions workflow run in GitHub when an Artifact is still in storage, I can see it in the GitHub ui with the associated workflow run. It looks like these Artifacts haven't been deleted in quite a while automatically. I verified this by looking at previous runs prior to the error and noticed the delete-artifact job in question previously produced a log of:
Run geekyeggo/delete-artifact@v1
with:
name: net-app
failOnError: true
env:
AZURE_HTTP_USER_AGENT:
Warning: Unable to delete artifact "net-app"; the artifact was not found.
So, it seems like in some ways this script was always broken, but in other ways that things have changed since it is no longer a warning and now an error.
I'm going to include the script we use as a reference.
name: Prod - Build and deploy ASP.Net Core app to Azure Web App - Coffee
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-net-app:
runs-on: windows-latest
env:
ArtifactName: net-app-${{ github.run_number }}
steps:
- uses: actions/checkout@v2
- name: Set up Node.js v16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true
- name: Sets the environment for PROD
run: .\DeploymentScripts\Configure-Net-App-Prod.ps1
shell: powershell
- name: Build CoffeeSPA.Web
run: dotnet build --configuration Release CoffeeSPA.Web\CoffeeSPA.Web.csproj
- name: Build CoffeeSPA.Worker
run: dotnet build --configuration Release CoffeeSPA.Worker\CoffeeSPA.Worker.csproj
- name: Publish CoffeeSPA.Web
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/Web CoffeeSPA.Web\CoffeeSPA.Web.csproj
- name: Publish CoffeeSPA.Worker
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/Web/app_data/jobs/continuous/CoffeeSPA.Worker CoffeeSPA.Worker\CoffeeSPA.Worker.csproj
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: net-app
path: ${{env.DOTNET_ROOT}}/Web
deploy-net-app:
runs-on: windows-latest
needs:
- build-net-app
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: net-app
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'coffee'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }}
package: .
- name: Delete artifact
uses: geekyeggo/delete-artifact@v1
with:
name: net-app
failOnError: true
So... what exactly is the remediation here to make sure Artifacts are deleted correctly? Is it delete-artifact@v1 that's the problem? Is it the GitHub Actions workflow script above? Is it a mixture of both?
I suspect the "net-app"'s final upload destination from the Workflow script (ex: https://productionresultssa14.blob.core.windows/actions-results/some GUID/workflow-job-run-some-GUID/artifacts/some-GUID.zip) isn't being carried through the script to the delete step/job geekyeggo/delete-artifact@v1, but I'm not sure on that.
Share Improve this question asked Mar 16 at 1:25 Lucas RappetteLucas Rappette 11 bronze badge 1- Update artifact name to match across all steps and use actions/delete-artifact@v3 instead of geekyeggo/delete-artifact@v1 for better reliability. – Sirra Sneha Commented Mar 17 at 4:09
1 Answer
Reset to default 0The error you're encountering is because the delete-artifact@v1
action is failing to locate the uploaded artifact.
In your upload-artifact step, the artifact is named
net-app
, but the environment variable (ArtifactName
) is set asnet-app-${{ github.run_number }}
. This mismatch causes the delete-artifact step to look fornet-app
, which may not exist if the artifact was uploaded with a different name, leading to the failure.Please refer this github doc for better understanding of upload/delete artifacts.
GitHub auto-deletes artifacts after a set period (default 90 days). If already deleted,
delete-artifact
may show a `404` error.
To resolve the issue,
Use the same artifact name across upload, download, and delete steps:
env:
ArtifactName: net-app
Replace
geekyeggo/delete-artifact@v1
withactions/delete-artifact@v3
, as it's the official version.Add
continue-on-error
to Prevent Failures,
If the artifact is already deleted, it avoids breaking the workflow.
Here's the complete Workflow file after making above changes.
Workflow file:
name: Prod - Build and deploy ASP.Net Core app to Azure Web App - Coffee
on:
push:
branches:
- main
workflow_dispatch:
env:
ArtifactName: net-app
jobs:
build-net-app:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Build CoffeeSPA.Web
run: dotnet build --configuration Release CoffeeSPA.Web\CoffeeSPA.Web.csproj
- name: Publish CoffeeSPA.Web
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/Web CoffeeSPA.Web\CoffeeSPA.Web.csproj
- name: Upload artifact for deployment
uses: actions/upload-artifact@v4
with:
name: ${{ env.ArtifactName }}
path: ${{env.DOTNET_ROOT}}/Web
deploy-net-app:
runs-on: windows-latest
needs: build-net-app
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: ${{ env.ArtifactName }}
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'coffee'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE }}
package: .
- name: Delete artifact (Ignore if not found)
uses: actions/delete-artifact@v3
continue-on-error: true
with:
name: ${{ env.ArtifactName }}