This repository has been archived by the owner on Mar 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (78 loc) · 3.92 KB
/
liquid-ci-cd-aws-cartridge.yml
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
90
91
92
93
94
95
# CI & CD workflow
name: CI/CD - Messaging.Aws Cartridge for Liquid Application Framework
on:
push:
branches: [ main ]
paths:
- 'src/Liquid.Messaging.Aws/**'
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened]
paths:
- 'src/Liquid.Messaging.Aws/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Job Type
run: |
if [$GITHUB_EVENT_NAME == 'push']
then
echo "Starting CD Job: Build, Test, Analyze, Pack and Publish library to Nuget.org..."
else
echo "Starting CI Job: Build, Test and Analyze..."
fi
- name: (CI) Checkout repo on Pull Request
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0 # required to eliminate shallow clone warning in Sonarcloud analysis
- name: (CI/CD) Checkout repo
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@v2
with:
fetch-depth: 0 # required to eliminate shallow clone warning in Sonarcloud analysis
# required by sonarcloud scanner
- name: (CI/CD) Setup Java JDK
uses: actions/[email protected]
with:
# The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28
java-version: 11.x
- name: (CI/CD) Setup .NET Core SDK
uses: actions/[email protected]
with:
# SDK version to use. Examples: 2.2.104, 3.1, 3.1.x
dotnet-version: 3.1.x
# required by sonarcloud scanner
- name: (CI/CD) Setup Sonar Scanner tool
run: dotnet tool install --global dotnet-sonarscanner
- name: (CI/CD) Install Test Reporting Tool
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: (CI/CD) Restore dependencies
run: dotnet restore src/Liquid.Messaging.Aws/Liquid.Messaging.Aws.csproj
# required to run tests that depends on AWS Services
- name: Parse Secrets
uses: jwsi/secret-parser@v1
with:
filename: test/Liquid.Messaging.Aws.Tests/appsettings.json
secret-name: LIQUID_MESSAGING_AWS_TEST_CONNECTIONS
secret-value: ${{ secrets.LIQUID_MESSAGING_AWS_TEST_CONNECTIONS }}
- name: (CI/CD) Build and Analyze Project
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_AWS }}
run: |
dotnet sonarscanner begin /k:"Avanade_Liquid.Messaging.Aws" /o:"avanade-1" /d:sonar.login="${{secrets.SONAR_TOKEN_AWS}}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vstest.reportsPaths=$GITHUB_WORKSPACE/testresults/*.trx /d:sonar.coverageReportPaths=$GITHUB_WORKSPACE/coverlet/reports/SonarQube.xml
dotnet build src/Liquid.Messaging.Aws/Liquid.Messaging.Aws.csproj --configuration Release --no-restore
dotnet test test/Liquid.Messaging.Aws.Tests/*Tests.csproj --collect:"XPlat Code Coverage" --logger trx --results-directory $GITHUB_WORKSPACE/testresults
reportgenerator -reports:$GITHUB_WORKSPACE/testresults/**/coverage.cobertura.xml -targetdir:$GITHUB_WORKSPACE/coverlet/reports -reporttypes:"SonarQube"
dotnet sonarscanner end /d:sonar.login="${{secrets.SONAR_TOKEN_AWS}}"
- name: (CD) Nuget Pack & Push to Nuget.org
if: ${{ github.event_name == 'push' }}
run: |
dotnet pack --no-build --configuration Release src/Liquid.Messaging.Aws/Liquid.Messaging.Aws.csproj --output .
dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}} --skip-duplicate