Fix PR actions workflow 3 #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR actions | |
on: | |
issue_comment: | |
types: [created, edited] | |
jobs: | |
publish: | |
name: Publish PR packages | |
runs-on: ubuntu-latest | |
if: github.event.issue.pull_request && contains(github.event.comment.body, '/publish') | |
env: | |
DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE: false | |
steps: | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.0.x | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ format('refs/pull/{0}/head', github.event.issue.number) }} | |
fetch-depth: 0 | |
- name: Build PR release version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
dotnet tool restore | |
sha=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefOid | jq -r '.headRefOid') | |
branch=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefName | jq -r '.headRefName' | sed 's/.*\///') | |
version=$(dotnet minver --tag-prefix v --ignore-height --default-pre-release-identifiers preview.0).$branch.$sha | |
echo "MINVERVERSIONOVERRIDE=$version" >> $GITHUB_ENV | |
echo $version | |
- name: Build | |
run: | | |
dotnet build AppLibDotnet.sln -v m -c Release | |
- name: Test | |
run: | | |
dotnet test AppLibDotnet.sln -v m --no-restore --no-build -c Release | |
- name: Pack PR release | |
run: | | |
dotnet pack AppLibDotnet.sln -v m --no-restore --no-build -c Release -p:Deterministic=true | |
- name: Versions | |
run: | | |
dotnet --version | |
- name: Publish PR release | |
run: | | |
dotnet nuget push src/**/bin/Release/*.nupkg --source https://nuget.pkg.github.com/Altinn/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate | |
- uses: actions/github-script@v7 | |
name: Comment on PR | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Published ${process.env.MINVERVERSIONOVERRIDE}` | |
}) |