Merge pull request #2 from nager/dependabot/github_actions/actions/ch… #13
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: Build and Deploy | |
on: | |
push: | |
paths: | |
- 'src/**' | |
- '.github/workflows/**' | |
branches: [ main ] | |
pull_request: | |
paths: | |
- 'src/**' | |
- '.github/workflows/**' | |
branches: [ main ] | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Restore dependencies | |
run: dotnet restore ./src | |
- name: Build | |
run: dotnet build ./src --configuration Release --no-restore | |
pack-and-push: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.event_name != 'pull_request' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Build and pack NuGet package | |
run: | | |
dotnet pack ./src/Nager.KeyValueParser/Nager.KeyValueParser.csproj \ | |
--configuration Release \ | |
--output $GITHUB_WORKSPACE/out | |
- name: Push NuGet package | |
run: | | |
dotnet nuget push $GITHUB_WORKSPACE/out/*.nupkg \ | |
--source https://api.nuget.org/v3/index.json \ | |
--api-key ${{ secrets.NUGET_TOKEN }} \ | |
--skip-duplicate | |
dependabot: | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ github.actor == 'dependabot[bot]' }} | |
steps: | |
- name: Dependabot metadata | |
id: dependabot-metadata | |
uses: dependabot/fetch-metadata@v2 | |
- name: Enable auto-merge for Dependabot PRs | |
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch'}} | |
run: gh pr merge --auto --merge "$PR_URL" | |
env: | |
PR_URL: ${{github.event.pull_request.html_url}} | |
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |