-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (137 loc) · 5.7 KB
/
updateDbDevices.yaml
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
name: Remove/Update Devices in the Database
on:
workflow_dispatch:
inputs:
select_index:
type: choice
description: Index as test or live
options:
- Test
- Live
default: "Test"
select_action:
type: choice
description: Select what you want to do
options:
- Set sdk_support
- Remove Devices
default: "Set SDKToDevice"
regex:
type: string
description: Regex of Device uids to use
default: "PIC32MZ2048EFH144|MCU_CARD_10_FOR_KINETIS_MK60DN512VLQ10"
delete_device:
type: boolean
description: Remove Device completely? (only used for "Remove Devices" option, clears only sdk_support if not checked)
default: false
xc8_specific:
type: boolean
description: Set XC8 support? (only used for "Set sdk_support" option)
default: false
AI_generated_sdk:
type: boolean
description: AI generated SDK? (only used for "Set sdk_support" option)
default: false
jobs:
Update_Devices_in_Dev_Database:
if: ${{ github.event.inputs.select_index == 'Test' }}
runs-on: ubuntu-latest
steps:
- name: Authorize Mikroe Actions App
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.MIKROE_ACTIONS }}
private-key: ${{ secrets.MIKROE_ACTIONS_KEY_AUTHORIZE }}
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/requirements/shared.txt
pip install -r scripts/requirements/databases.txt
sudo apt-get install p7zip-full
- name: Upload new database asset
run: |
python -u scripts/update_devices_db.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} "Test" "${{ github.event.inputs.select_action }}" "${{ github.event.inputs.regex }}" ${{ github.event.inputs.delete_device }} ${{ github.event.inputs.xc8_specific }} "--ai_sdk" ${{ github.event.inputs.AI_generated_sdk }}
- name: Add GitHub Actions credentials
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Commit and Push Changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Updating with new dev database";
git add necto_db_dev.db
git commit -m "Updated necto dev database with latest merged release."
git push
curl --location --request POST '${{ secrets.ERP_DB_IMPORT_API }}' \
--header 'Authorization: Basic ${{ secrets.ERP_DB_IMPORT_KEY }}'
else
echo "No changes made to necto_db_dev.db";
fi
- name: Run Index Script
env:
ES_HOST: ${{ secrets.ES_HOST }}
ES_USER: ${{ secrets.ES_USER }}
ES_PASSWORD: ${{ secrets.ES_PASSWORD }}
run: |
echo "Indexing database to TEST."
python -u scripts/index.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.ES_INDEX_TEST }} ${{ secrets.PROG_DEBUG_CODEGRIP }} "True" "latest" "True" "False"
Update_Devices_in_Live_Database:
if: ${{ github.event.inputs.select_index == 'Live' }}
runs-on: ubuntu-latest
steps:
- name: Authorize Mikroe Actions App
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.MIKROE_ACTIONS }}
private-key: ${{ secrets.MIKROE_ACTIONS_KEY_AUTHORIZE }}
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/requirements/shared.txt
pip install -r scripts/requirements/databases.txt
sudo apt-get install p7zip-full
- name: Upload new database asset
run: |
python -u scripts/update_devices_db.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} "Live" "${{ github.event.inputs.select_action }}" "${{ github.event.inputs.regex }}" ${{ github.event.inputs.delete_device }} ${{ github.event.inputs.xc8_specific }} "--ai_sdk" ${{ github.event.inputs.AI_generated_sdk }}
- name: Add GitHub Actions credentials
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Commit and Push Changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Updating with new live database";
git add necto_db.db
git commit -m "Updated necto live database with latest merged release."
git push
curl --location --request POST '${{ secrets.ERP_DB_IMPORT_API }}' \
--header 'Authorization: Basic ${{ secrets.ERP_DB_IMPORT_KEY }}'
else
echo "No changes made to necto_db.db";
fi
- name: Run Index Script
env:
ES_HOST: ${{ secrets.ES_HOST }}
ES_USER: ${{ secrets.ES_USER }}
ES_PASSWORD: ${{ secrets.ES_PASSWORD }}
run: |
echo "Indexing database to LIVE."
python -u scripts/index.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.ES_INDEX_LIVE }} ${{ secrets.PROG_DEBUG_CODEGRIP }} "True" "latest" "True" "False"