-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (97 loc) · 3.66 KB
/
reset-demo.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
on:
workflow_dispatch:
name: 🔥 Reset Demo Content
env:
DOTNET_VERSION: '6.0'
ARTIFACT_DIR: './artifacts'
jobs:
build-provisioning:
name: 🏢 Build Provisioning Tool
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: 🔧 Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: 🏗️ Build Solution
shell: pwsh
run: |
mkdir ${{ env.ARTIFACT_DIR }}
dotnet publish ./src/CopyTheWorld/CopyTheWorld.Provisioning/CopyTheWorld.Provisioning.csproj --configuration Release --sc -r win-x64
Copy-Item -Path "./src/CopyTheWorld/CopyTheWorld.Provisioning/bin/Release/net6.0/win-x64/*" -Destination "${{ env.ARTIFACT_DIR }}" -Recurse
- name: ⬆️ Upload Artifact
uses: actions/upload-artifact@v3
with:
name: artifacts
path: ${{ env.ARTIFACT_DIR }}
reset-digital-twins:
name: 🔥👬 Reset Digital Twins
runs-on: windows-latest
needs: [build-provisioning]
steps:
- uses: actions/checkout@v3
- name: ⬇️ Download artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
- name: 🔑 Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 💾 Install Azure IoT Extension
shell: pwsh
run: az extension add -n azure-iot
- name: 🔥 Reset Azure Digital Twins
shell: pwsh
run: |
$adtName = az dt list -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --query [0].name --output tsv
az dt twin delete-all -n $adtName -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -y
az dt model delete-all -n $adtName -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} -y
az dt model create -n $adtName -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --fd ./ontology
- name: 👬 Create new twins and relationships
shell: pwsh
run: |
$adtEndpoint = az dt list -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --query [0].hostName --output tsv
./CopyTheWorld.Provisioning.exe twins populate --file "./config/ctw.xlsx" --adtEndpoint https://$adtEndpoint
add-devices:
name: 🌐 Add Devices
runs-on: windows-latest
needs: [build-provisioning]
steps:
- uses: actions/checkout@v3
- name: ⬇️ Download artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
- name: 🔑 Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 💾 Install Azure IoT Extension
shell: pwsh
run: az extension add -n azure-iot
- name: 🌐 Create all devices
shell: pwsh
run: |
$iotHub = az iot hub list -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --query [0].properties.hostName --output tsv
./CopyTheWorld.Provisioning.exe iothub populate --file "./config/ctw.xlsx" --iotHub $iotHub
create-mapping:
name: 🗺️ Create Mapping
runs-on: windows-latest
needs: [build-provisioning]
steps:
- uses: actions/checkout@v3
- name: ⬇️ Download artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
- name: 🔑 Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 🗺️ Create mapping
shell: pwsh
run: |
$storageEndpoint = az storage account list -g ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --query [0].primaryEndpoints.table --output tsv
./CopyTheWorld.Provisioning.exe mapping create --file "./config/ctw.xlsx" --storageEndpoint "$($storageEndpoint)mapping"