-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (94 loc) · 3.09 KB
/
main_fefezfezf.yml
File metadata and controls
115 lines (94 loc) · 3.09 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
name: Docker App (good fefezfezf)
on:
workflow_dispatch:
env:
EXPECTED_RESPONSE: "Hello World!" # 🔹 Définition de la variable globale
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Publish app
run: dotnet publish -c Release -o publish
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dotnet-publish
path: publish/
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Run tests
run: dotnet test
docker-build:
runs-on: ubuntu-latest
needs: [build, test]
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to registry
uses: docker/login-action@v2
with:
registry: https://index.docker.io/v1/
username: ${{ secrets.AzureAppService_ContainerUsername_007dc16c00194a579ee0e182f3912414 }}
password: ${{ secrets.AzureAppService_ContainerPassword_03b591a7c15d426aa4439cb5a79e30b8 }}
- name: Build and push container image to registry
uses: docker/build-push-action@v3
with:
push: true
tags: forsanta/webapi-starter-dotnet8:${{ github.sha }}
file: ./Dockerfile
deploy:
runs-on: ubuntu-latest
needs: [docker-build, test] # 🔹 attend build & test avant de lancer
environment:
name: production
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
outputs:
webapp-url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: dotnet-publish
path: ./publish
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: fefezfezf
slot-name: production
publish-profile: ${{ secrets.AzureAppService_PublishProfile_9b585dbfa0374924ab161fec5b2dea00 }}
images: forsanta/webapi-starter-dotnet8:${{ github.sha }}
check-url:
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Vérifier que l’URL retourne la valeur attendue
run: |
url="${{ needs.deploy.outputs.webapp-url }}"
echo "Test de l'URL : $url"
response=$(curl -s "$url")
echo "Réponse : $response"
if [ "$response" != "$EXPECTED_RESPONSE" ]; then
echo "❌ L'URL ne retourne pas '$EXPECTED_RESPONSE'"
exit 1
fi
echo "✅ L'URL retourne bien '$EXPECTED_RESPONSE'"