I am using another Git Repo as library, which uses a different .net Version and has missing Permissions to be build on Action.
How do i exclude this/all sub modules from being built ?
Error Codes being Produced:
error MSB3191: Unable to create directory "obj/Debug/". Access to the path '/home/runner/work/Repo/Project/Submodule/Folder/obj/Debug/' is denied.
error MSB3644: The reference assemblies for .NETFramework,Version=v2.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application...
Workflow File (dotnet.yml)
name: .NET
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: textbook/git-checkout-submodule-action#master
- name: Setup .NET
uses: actions/setup-dotnet#v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
Related
I have a class library project that I keep in a private GitHub repo. I set up a GitHub action to create a NuGet package and push it to my private NuGet registry on GitHub.
The build process is working fine but getting stuck at NuGet push because it's unable to find the directory where the NuGet package is created. The error I get is:
Run dotnet nuget push "bin/Release/MyPackage.1.2.0.nupkg" --source
"github"
error: Could not find a part of the path
'/home/runner/work/my-package/my-package/bin/Release'.
Here's the yaml file for this job:
name: Publish MyPackage NuGet to GitHub Packages
on:
pull_request:
branches: [ "master" ]
jobs:
build-pack-n-ship:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Setup .NET
uses: actions/setup-dotnet#v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Create NuGet package
run: dotnet pack --configuration Release
- name: Get version
uses: kzrnm/get-net-sdk-project-versions-action#v1
id: get-version
with:
proj-path: MyProject/MyProject.csproj
- name: Add Package Source
run: dotnet nuget add source --username MY_USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/MY_ORGANIZATION/index.json"
- name: Publish to GitHub Packages
run: dotnet nuget push "bin/Release/MyProject.${{ steps.get-version.outputs.version }}.nupkg" --source "github"
I think I need to specify the location of the working directory before the
"bin/Release/MyProject.${{ steps.get-version.outputs.version }}.nupkg" --source "github" but I wasn't able to get it right.
BTW, the part where I get the version number for my NuGet package is working fine. So I know that's not where the problem is.
Any idea how I can fix this?
I have a repository with some subdirectories. One of the subdirectory is called gradle-specific which is the gradle project. I want to run ./gradlew clean build using github actions. My yaml file looks as follows:
name: Java CI with Gradle
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./gradle-specific
steps:
- uses: actions/checkout#v3
- name: Set up JDK 16
uses: actions/setup-java#v3
with:
java-version: '16'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action#67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: clean build
but error logs indicate that the build is happening in the root folder itself:
Error: Error: Cannot locate a Gradle wrapper properties file at '/home/runner/work/service-commons/service-commons/gradle/wrapper/gradle-wrapper.properties'. Specify 'gradle-version' or 'gradle-executable' for projects without Gradle wrapper configured.
where service-commons is my repository name
I tried specifying the working directory without relative path, with relative path, specifying globally. I am following https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun to configure the same
The following workflow.yml works as expected when comitting changes to my main branch for our Flutter web based application.
name: Build and deploy Node.js app to Azure Web App - myApp
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up Node.js version
uses: actions/setup-node#v1
with:
node-version: '12.x'
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy#v2
with:
app-name: 'myApp'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_MYAPP }}
package: .
But we are challenged to make the workflow to publish to an additional dev and beta branch, so that the website branches could be addressed like this:
main: myapp.azurewebsites.net
beta: beta.myapp.azurewebsites.net
dev: dev.myapp.azurewebsites.net
So how should the workflow.yml be to publish those two additional branches ?
Do I need to do some more in azure setting/enviroment or github to make it work ?
The branches in github are named 'main', 'beta' and 'dev'.
I have the following GitHub actions workflow for a C# (.net 6) project that works fine with ubuntu-latest. But for some reason we need it to use windows-latest, it breaks with the error (the error after yaml workflow).
Yaml workflow:
jobs:
build:
name: Create Release
runs-on: windows-latest
steps:
- name: Setup Checkout
uses: actions/checkout#v2
- name: Setup .NET
uses: actions/setup-dotnet#v1
with:
dotnet-version: 6.0.x
- name: Restore .NET dependencies
run: dotnet restore
- name: Build .NET
run: dotnet build --no-restore
- name: Test .NET
run: dotnet test --no-build --verbosity normal
- name: Publish .NET
run: |
dotnet publish /p:PublishProfile=Release-win-x86 -c Release
dotnet publish /p:PublishProfile=Release-win-x64 -c Release
- name: Upload Published Artifact
uses: actions/upload-artifact#v2
with:
name: softwarename
path: |
/home/runner/work/solution/project/Software/win-x86/
/home/runner/work/solution/project/Software/win-x64/
The error:
Upload Published Artifact
Run actions/upload-artifact#v2
Warning: No files were found with the provided path:
/home/runner/work/solution/project/Software/win-x86/
/home/runner/work/solution/project/Software/win-x64/. No artifacts will be uploaded.
Download Published Artifact
Run actions/download-artifact#v2
Starting download for softwarename
Error: Unable to find any artifacts for the associated workflow
I read here that I need to change actions/upload-artifact#v2 to actions/upload-artifact#v2.2.4, that I tried and failed with the same error.
Any Idea how to fix this issue?
I give credit for #jessehouwing for making me a ware of the concept.
Regarding this thread, my solution needed ${{ github.workspace }}, so that my changes looks like this:
${{ github.workspace }}\Software\win-x86
${{ github.workspace }}\Software\win-x64
Don't rely on:
/home/runner/work/solution/project
Instead use
${{ github.workspace }}/project
That way it points to the correct path for the runner independent of the operating system and configuration
I have the following action on Github actions that automatically packs and deploy a package to nuget.org every time a PR gets merged into master.
name: Nuget Deploy
on:
push:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout#v2
- name: Setup .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: 3.1.101
- name: Generate Nuget package
run: dotnet pack
working-directory: DateOverride
- name: Deploy to nuget.org
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_DEPLOY_KEY }} -s https://api.nuget.org/v3/index.json
working-directory: DateOverride/DateOverride/bin/Debug
But I would like that it was not run if my update is only a README.md update, is it possible to do so?
I'd think the paths-ignore setting should help:
on:
push:
branches:
- master
paths-ignore:
- '**/README.md'
You might want to combine your current GitHiub Action with another like MarceloPrado/has-changed-path
This action outputs whether a path or combination of paths has changed in the previous commit.
[This] action is meant to be used inside your job steps, not at the root of your workflow file
Or (opposite filter): dorny/paths-filter
With this Github Action you can execute your workflow steps only if relevant files are modified.