-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (81 loc) · 3.75 KB
/
updateDbFromSdk.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
name: Update Latest Database From mikroSDK
on:
repository_dispatch:
types: [trigger-workflow]
jobs:
Update-Database-From-mikroSDK:
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:
ref: ${{ github.event.client_payload.sha }}
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: Extract payload version
id: mikrosdk_payload
run: |
echo "tag_version=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT
echo "index=${{ github.event.client_payload.index }}" >> $GITHUB_OUTPUT
- name: Upload new database asset
run: |
if [[ ${{ steps.mikrosdk_payload.outputs.index }} == "Live" ]]; then
python -u scripts/reupload_databases.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ secrets.PROG_DEBUG_CODEGRIP_LIVE }} ${{ secrets.PROG_DEBUG_MIKROPROG }} "latest" ${{ steps.mikrosdk_payload.outputs.tag_version }} ${{ steps.mikrosdk_payload.outputs.index }}
else
python -u scripts/reupload_databases.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ secrets.PROG_DEBUG_CODEGRIP_TEST }} ${{ secrets.PROG_DEBUG_MIKROPROG }} "latest" ${{ steps.mikrosdk_payload.outputs.tag_version }} ${{ steps.mikrosdk_payload.outputs.index }}
fi
- 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 [[ ${{ steps.mikrosdk_payload.outputs.index }} == "Live" ]]; then
DB_NAME="necto_db.db"
else
DB_NAME="necto_db_dev.db"
fi
STATUS=$(git status --short "$DB_NAME")
if [ -z "$STATUS" ]; then
echo "No changes made to $DB_NAME";
else
echo "Updating with new $DB_NAME";
echo "test"
git pull
git add $DB_NAME
git commit -m "Updated $DB_NAME with latest merged release."
git push
if [[ ${{ steps.mikrosdk_payload.outputs.index }} == "Live" ]]; then
curl --location --request POST '${{ secrets.ERP_DB_IMPORT_API }}' \
--header 'Authorization: Basic ${{ secrets.ERP_DB_IMPORT_KEY }}'
fi
fi
- name: Run Index Script
env:
ES_HOST: ${{ secrets.ES_HOST }}
ES_USER: ${{ secrets.ES_USER }}
ES_PASSWORD: ${{ secrets.ES_PASSWORD }}
run: |
if [[ ${{ steps.mikrosdk_payload.outputs.index }} == "Test" ]]; then
echo "Indexing database to TEST."
python -u scripts/index.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.ES_INDEX_TEST }} ${{ secrets.PROG_DEBUG_CODEGRIP_TEST }} "True" "latest" "True" "False"
fi
if [[ ${{ steps.mikrosdk_payload.outputs.index }} == "Live" ]]; then
echo "Indexing database to LIVE."
python -u scripts/index.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.ES_INDEX_LIVE }} ${{ secrets.PROG_DEBUG_CODEGRIP_LIVE }} "True" "latest" "True" "False"
fi