-
Notifications
You must be signed in to change notification settings - Fork 3
170 lines (164 loc) · 5.43 KB
/
Copy pathdotnet.yml
File metadata and controls
170 lines (164 loc) · 5.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: dotnet
on:
push:
paths:
- "samples/dotnet/**"
- ".github/workflows/dotnet.yml"
- "restarter/**"
schedule:
- cron: '0 7 * * *'
env:
REGISTRY: ghcr.io
IMAGE_NAME: miracl/oidc-samples/samples/dotnet
DOCKER_BUILD_CONTEXT: samples/dotnet
SAMPLE_IMAGE: ghcr.io/miracl/oidc-samples/samples/dotnet:${{ github.sha }}
PROXY_IMAGE: ghcr.io/miracl/oidc-samples/proxy:latest-windows
TESTS_IMAGE: ghcr.io/miracl/oidc-samples/integration-tests:latest-windows
CLIENT_ID: ${{ vars.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
PROJECT_DOMAIN: ${{ vars.PROJECT_DOMAIN }}
CID_FILE: sample.cid
jobs:
build-dotnet:
runs-on: windows-2025
steps:
- uses: actions/checkout@v7
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v3
- name: Setup NuGet
uses: NuGet/setup-nuget@v3
- name: Restore Packages
run: nuget restore samples/dotnet/OidcSample.sln
- name: Build Solution
run: |
msbuild.exe samples/dotnet/OidcSample.sln /p:platform="Any CPU" /p:configuration="Release"
build-docker:
needs: build-dotnet
runs-on: windows-2025
steps:
- uses: actions/checkout@v7
- uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ github.sha }}
- name: Docker login, build & push
run: |
docker build --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest samples/dotnet/
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest ${{ steps.meta.outputs.tags}}
docker push ${{ steps.meta.outputs.tags}}
run-integration-tests-with-proxy:
needs: build-docker
runs-on: windows-2025
steps:
- name: Pull images
run: |
docker pull --quiet ${{ env.PROXY_IMAGE }}
docker pull --quiet ${{ env.SAMPLE_IMAGE }}
docker pull --quiet ${{ env.TESTS_IMAGE }}
- name: Start the proxy
run: docker run
--detach
--publish 8080:8080
--cidfile ${{ env.CID_FILE }}
${{ env.PROXY_IMAGE }}
- name: Checkout repository content
uses: actions/checkout@v7
- name: Run the restarter
run: go run ./restarter/main.go &
- name: Sleep for a seconds
run: sleep 1s
shell: bash
- name: Proxy info
id: proxy
shell: bash
run: |
export CID=$(cat $CID_FILE)
export ADDR=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CID)
echo "address=$ADDR" >> $GITHUB_OUTPUT
rm -rf $CID_FILE
- name: Start the sample
shell: bash
run: docker run
--detach
--publish 8000:8000
--name sample
--env CLIENT_ID
--env CLIENT_SECRET
--env ISSUER=$PROJECT_DOMAIN
--env REDIRECT_URL=http://sample:8000/login
--env PROXY_HOST=${{ steps.proxy.outputs.address }}
--env PROXY_PORT=8080
--cidfile $CID_FILE
${{ env.SAMPLE_IMAGE }}
- name: Sleep for 10 seconds
run: sleep 10s
shell: bash
- name: Sample info
id: sample
shell: bash
run: |
export CID=$(cat $CID_FILE)
export ADDR=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CID)
echo "address=$ADDR" >> $GITHUB_OUTPUT
- name: Run integration tests
id: tests
shell: powershell
run: docker run
--env CLIENT_ID
--env CLIENT_SECRET
--env PROJECT_DOMAIN
--env SAMPLE_NAME=sample
--env SAMPLE_IP=${{ steps.sample.outputs.address }}
--env SAMPLE_URL=http://sample:8000
--env REDIRECT_URL=http://sample:8000/login
--env SKIP_MODIFY_TESTS=false
${{ env.TESTS_IMAGE }}
run-integration-tests:
needs: build-docker
runs-on: windows-2025
steps:
- name: Pull images
run: |
docker pull --quiet ${{ env.SAMPLE_IMAGE }}
docker pull --quiet ${{ env.TESTS_IMAGE }}
- name: Start the sample
shell: bash
run: docker run
--detach
--publish 8000:8000
--env CLIENT_ID
--env CLIENT_SECRET
--env ISSUER=$PROJECT_DOMAIN
--env REDIRECT_URL=http://sample:8000/login
--cidfile $CID_FILE
${{ env.SAMPLE_IMAGE }}
- name: Sleep for 2 seconds
run: sleep 2s
shell: bash
- name: Info
id: info
shell: bash
run: |
export CID=$(cat $CID_FILE)
export ADDR=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CID)
echo "address=$ADDR" >> $GITHUB_OUTPUT
- name: Run integration tests
id: tests
shell: powershell
run: docker run
--env CLIENT_ID
--env CLIENT_SECRET
--env PROJECT_DOMAIN
--env SAMPLE_IP=${{ steps.info.outputs.address }}
--env SAMPLE_URL=http://sample:8000
--env REDIRECT_URL=http://sample:8000/login
--env SKIP_MODIFY_TESTS=true
${{ env.TESTS_IMAGE }}