Out of the blue we got this error during a build:
Current runner version: '2.320.0'
Operating System
Runner Image
Runner Image Provisioner
GITHUB_TOKEN Permissions
Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Error: This request has been automatically failed because it uses a deprecated version of actions/upload-artifact: v2. Learn more: https://github.blog/changelog/2024-02-13-deprecation-notice-v1-and-v2-of-the-artifact-actions/
Our workflow yaml file was very old and had been generated by Azure a long time ago for our web app. How to fix it?
As well as this upload-artifact being out of date there’s more we should do at the same time:
actions/checkout@v2
: Update to actions/checkout@v3
.actions/setup-dotnet@v1
: Update to actions/setup-dotnet@v3
.actions/upload-artifact@v2
: Update to actions/upload-artifact@v3
.actions/download-artifact@v2
: Update to actions/download-artifact@v3
.azure/webapps-deploy@v2
: The latest stable version is v3
, so update it to azure/webapps-deploy@v3
.
So we did this and then the build failed again with a new error:
Run dotnet publish -c Release -o C:\Program Files\dotnet/myapp
MSBUILD : error MSB1009: Project file does not exist.
Switch: Files\dotnet/myapp
Workload updates are available. Run dotnet workload list for more information.
Error: Process completed with exit code 1.
Looking in our yaml I see lines like this:
${{env.DOTNET_ROOT}}/myapp
This is what was throwing the error. This worked with the old versions but apparently not with the new ones!
ChatGPT suggested changing it to:
${{ runner.workspace }}/myapp
Whilst GitHub CoPilot suggested:
${{env.DOTNET_ROOT}}/myapp
For us, we went with ${{ runner.workspace }}/myapp. ChatGPT argued the following:
“In this context, ${{ runner.workspace }}
is generally better for the following reasons:
- Write Permissions:
${{ runner.workspace }}
is a dedicated directory within the GitHub Actions environment that’s guaranteed to have write permissions. Using it minimizes the risk of permission-related issues that can occur with paths like${{ env.DOTNET_ROOT }}
, which can point to system directories where write access is restricted. - Isolation and Clarity:
${{ runner.workspace }}
is specific to each job in the workflow and provides a clean, isolated location for artifacts and outputs. This ensures that your workflow’s output directory is consistent and separate from system directories or environment-based paths like${{ env.DOTNET_ROOT }}
. - Flexibility for Artifact Management: GitHub Actions workflows typically manage build artifacts within
${{ runner.workspace }}
since it supports seamless integration with steps likeupload-artifact
anddownload-artifact
.
For these reasons, ${{ runner.workspace }}
is a better choice for paths where you need to output or store files during the workflow’s execution. Use ${{ env.DOTNET_ROOT }}
only if you need to specifically reference the .NET SDK installation location, not for storing artifacts.”
So after this change the workflow ran fine.
Comments