-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (89 loc) · 2.69 KB
/
build-and-deploy.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
name: Build and Deploy
on:
push:
paths-ignore:
- '.gitignore'
- '.mergify.yml'
- 'CHANGELOG.md'
- 'LICENSE'
- 'README.md'
- 'renovate.json'
pull_request:
env:
AZURE_FUNCTIONAPP_NAME: ADTEventBroadcast
AZURE_FUNCTIONAPP_PACKAGE_PATH: "adt-event-endpoint-function"
DOTNET_VERSION: 8.0.x
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup DotNet
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Build the function
shell: bash
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
dotnet build --configuration Release --output ./output
popd
- name: Deploy to Azure Function
# Release only where secrets are available and only in main branch.
if: >-
github.ref == 'refs/heads/main'
&& !github.event.repository.fork
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
)
uses: Azure/functions-action@v1
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'
publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}
release:
concurrency:
# Allow only one release at a time.
group: release-${{ github.event.number || github.ref }}
needs:
- build-and-deploy
runs-on: ubuntu-latest
# Release only where secrets are available.
if: >-
!github.event.repository.fork
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
)
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
token: ${{ secrets.DEPLOYMENT_TOKEN }}
submodules: recursive
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.DEPLOYMENT_TOKEN }}
run: |
npm install
npx semantic-release
success:
runs-on: ubuntu-24.04
needs:
- build-and-deploy
- release
if: >-
always() && (
contains(join(needs.*.result, ','), 'failure')
|| !contains(join(needs.*.result, ','), 'cancelled')
)
steps:
- name: Verify that there were no failures
run: ${{ !contains(join(needs.*.result, ','), 'failure') }}