-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (141 loc) · 5.29 KB
/
build.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Build
on:
push:
branches:
- main
paths-ignore:
- .github/workflows/security-scanning.yml
- .github/workflows/skipped-build.yml
- '.vscode/**'
- 'docs/**'
- CONTRIBUTING.md
- LICENSE
- README.md
pull_request:
branches:
- main
paths-ignore:
- .github/workflows/security-scanning.yml
- .github/workflows/skipped-build.yml
- '.vscode/**'
- 'docs/**'
- CONTRIBUTING.md
- LICENSE
- README.md
permissions:
id-token: write
jobs:
build:
name: Build
runs-on: ubuntu-24.04
concurrency: build
permissions:
contents: write
env:
CREATE_RELEASE: ${{ github.ref_name == 'main' && !contains(github.event.head_commit.message, '[skip-release]') && !contains(github.event.head_commit.message, 'dependabot[bot]') }}
IS_FEATURE_PULL_REQUEST: ${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'features/') }}
CREATE_PRERELEASE: 'false'
PACKAGE_VERSION:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Azure Functions Core Tools
run: |
wget -q https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install azure-functions-core-tools-4
func version
# See https://github.com/Azure/azure-functions-core-tools/issues/3766
sudo chmod +x /usr/lib/azure-functions-core-tools-4/in-proc8/func
- name: Build
id: build
run: |
dotnet user-secrets set APPLICATIONINSIGHTS_CONNECTION_STRING '${{ secrets.APPLICATION_INSIGHTS_CONNECTION_STRING }}' --id 074ca336-270b-4832-9a1a-60baf152b727
./build.sh --package
env:
IntegrationTestServiceBusConnectionString: ${{ secrets.SERVICE_BUS_CONNECTION_STRING }}
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: './artifacts/test-results/**/*.html'
if-no-files-found: error
- name: Upload Functions logs
uses: actions/upload-artifact@v4
if: ${{ failure() && steps.build.conclusion == 'failure' }}
with:
name: function-logs
path: './artifacts/test-results/*.log'
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: code-coverage
path: artifacts/coverage-report
if-no-files-found: error
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: deploy
path: |
deploy
artifacts/out/package
artifacts/out/functions/*.zip
if-no-files-found: error
- name: Determine if we're skipping release on feature Pull Request
if: ${{ env.IS_FEATURE_PULL_REQUEST == 'true' }}
run: |
headCommitMessage=$(git log ${{ github.event.pull_request.head.sha }} -n 1 --format=%B)
echo "HEAD commit message is: $headCommitMessage"
if [[ $headCommitMessage != *"[skip-release]"* ]]; then
echo "CREATE_PRERELEASE=true" >> $GITHUB_ENV
fi
- name: Create GitHub release on main branch
if: ${{ env.CREATE_RELEASE == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
touch empty-release-notes.txt
gh release create ${{ env.PACKAGE_VERSION }} --title ${{ env.PACKAGE_VERSION }} ./artifacts/out/package/* --target ${{ github.sha }} --repo ${{ github.repository }} --notes-file empty-release-notes.txt
- name: Create GitHub prerelease on feature Pull Request
if: ${{ env.CREATE_PRERELEASE == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
touch empty-release-notes.txt
gh release create ${{ env.PACKAGE_VERSION }} --title ${{ env.PACKAGE_VERSION }} ./artifacts/out/package/* --target ${{ github.sha }} --repo ${{ github.repository }} --notes-file empty-release-notes.txt --prerelease
- name: Push NuGet package
if: ${{ env.CREATE_RELEASE == 'true' || env.CREATE_PRERELEASE == 'true' }}
run: dotnet nuget push ./artifacts/out/package/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
deploy:
name: Deploy
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
environment: PROD
needs: build
concurrency: deploy
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: deploy
- name: Sign-in to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID_1 }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Deploy
uses: azure/powershell@v2
with:
inlineScript: |
deploy/Deploy.ps1 -Location ${{ env.AZURE_LOCATION }} -ResourceNamePrefix ${{ env.RESOURCE_NAME_PREFIX }}
azPSVersion: 'latest'
env:
AZURE_LOCATION: australiaeast
RESOURCE_NAME_PREFIX: gabow