-
Notifications
You must be signed in to change notification settings - Fork 39
131 lines (116 loc) · 5.26 KB
/
boardCardReleaseTest.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
name: Release Boards/Cards from Branch to Test
on:
workflow_dispatch:
inputs:
release_branch:
type: string
description: Which Branch to release Boards from? (change last number to desired number)
default: "new-feature/boards_and_cards/1"
jobs:
upload_board_assets_dev:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
packages: write
actions: read
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.inputs.release_branch }} # Dynamically using the branch input
token: ${{ steps.app-token.outputs.token }}
- name: Add GitHub Actions credentials
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Fetch Master Branch
run: git fetch origin master
- name: Merge Master into ${{ github.event.inputs.release_branch }}
run: |
git merge origin/master --allow-unrelated-histories
# Check if there are changes to commit after the merge
if [ -n "$(git status --porcelain)" ]; then
echo "Merging master into ${{ github.event.inputs.release_branch }} branch created changes, committing them."
git add .
git commit -m "Merge master into ${{ github.event.inputs.release_branch }}"
git push
else
echo "No changes to commit after merging master."
fi
continue-on-error: false # Ensure the workflow stops if there's a conflict
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Cache Python packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install aiohttp
pip install aiofiles
pip install requests
pip install py7zr
pip install chardet
pip install elasticsearch==7.13.4
pip install packaging
pip install alive-progress
sudo apt-get install p7zip-full
- name: Update Changelogs
id: changelog_update
run: |
python -u scripts/update_board_changelog.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }}
sdk_tag=$(<sdk_tag.txt)
rm sdk_tag.txt
echo "SDK Tag name is mikroSDK-$sdk_tag"
echo "sdk_tag_name=mikroSDK-$sdk_tag" >> $GITHUB_OUTPUT
python -u scripts/log_changes.py
- name: Upload Board Asset
run: |
python -u scripts/package.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ steps.changelog_update.outputs.sdk_tag_name }} "True"
- name: Run Index Script
env:
ES_HOST: ${{ secrets.ES_HOST }}
ES_USER: ${{ secrets.ES_USER }}
ES_PASSWORD: ${{ secrets.ES_PASSWORD }}
ES_INDEX_TEST: ${{ secrets.ES_INDEX_TEST }}
ES_INDEX_LIVE: ${{ secrets.ES_INDEX_LIVE }}
MIKROE_NECTO_AWS: ${{ secrets.MIKROE_NECTO_AWS }}
run: |
echo "Indexing to Test."
python -u scripts/index.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ steps.changelog_update.outputs.sdk_tag_name }} ${{ secrets.ES_INDEX_TEST }} "False" "--board_card_only" "True"
- name: Trigger database update in Core repo
run: |
# Set the required variables
repo_owner="MikroElektronika"
repo_name="core_packages"
event_type="trigger-workflow"
version="${{ steps.changelog_update.outputs.sdk_tag_name }}"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.MIKROE_ACTIONS_KEY }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"version\": \"$version\", \"index\": \"Test\", \"unit\": false, \"integration\": true}}"
- name: Notify Mattermost - Test ready
env:
MATTERMOST_WEBHOOK_URL_SDK: ${{ secrets.MATTERMOST_WEBHOOK_URL_SDK }}
run: |
CURRENT_DATE=$(date +'%Y-%m-%d') # Get current date in YYYY-MM-DD format
MESSAGE="**SDK/BOARD/CARD package update ready to test for $CURRENT_DATE.**\n> Test using latest NECTO dev\n + [LIN](https://software-update.mikroe.com/NECTOStudio7/development/necto/linux/NECTOInstaller.zip)\n + [MAC](https://software-update.mikroe.com/NECTOStudio7/development/necto/macos/NECTOInstaller.dmg)\n + [WIN](https://software-update.mikroe.com/NECTOStudio7/development/necto/win/NECTOInstaller.zip)"
curl -X POST -H 'Content-Type: application/json' \
--data "{\"text\": \"$MESSAGE\"}" \
$MATTERMOST_WEBHOOK_URL_SDK