-
Notifications
You must be signed in to change notification settings - Fork 2
89 lines (77 loc) · 2.43 KB
/
ci-cd.yml
File metadata and controls
89 lines (77 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: 'CI/CD'
on:
- push
- workflow_dispatch
- pull_request
permissions:
id-token: write
contents: read
jobs:
build:
name: 'CI: Restore, Build & Test'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core SDKs
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Check if PR is from a fork
id: check_fork
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "is_pull_request=true" >> $GITHUB_ENV
else
echo "is_pull_request=false" >> $GITHUB_ENV
fi
- name: Configure AWS Credentials
if: env.is_pull_request == 'false'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-north-1
role-to-assume: ${{ secrets.DEPLOY_ROLE }}
role-session-name: OIDCSession
- name: Setup DynamoDB Local
run: docker run -d -p 8000:8000 amazon/dynamodb-local
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Lint
run: dotnet format --verify-no-changes --no-restore
- name: Test (Main)
if: env.is_pull_request == 'false'
run: dotnet test --no-build /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov
- name: Test (PR)
if: env.is_pull_request == 'true'
run: dotnet test ./test/AspNetCore.Identity.AmazonDynamoDB.Tests --no-build
- name: Publish Code Coverage
uses: codecov/codecov-action@v5
if: ${{ github.actor != 'dependabot[bot]' && env.is_pull_request == 'false' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: test/**/TestResults/coverage.info
fail_ci_if_error: false
publish:
name: 'CD: Pack & Publish'
needs: build
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core SDKs
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Pack
run: dotnet pack
- name: Publish
run: |
dotnet nuget push **\*.nupkg \
--source 'https://api.nuget.org/v3/index.json' \
--api-key ${{ secrets.NUGET_API_KEY }} \
--skip-duplicate