Skip to content

Commit

Permalink
Merge pull request #96 from MikroElektronika/improvement/mcu_release_…
Browse files Browse the repository at this point in the history
…workflow

Added workflow for releasing MCUs to test
  • Loading branch information
StrahinjaJacimovic authored Oct 4, 2024
2 parents 99786e6 + b27203f commit bd6902d
Show file tree
Hide file tree
Showing 4 changed files with 1,920 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/MCUsReleaseTest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Release MCUs from Branch to Test

on:
workflow_dispatch:
inputs:
release_branch:
type: string
description: Which Branch to release MCUs from? (change last number to desired number)
default: "new-feature/mcus/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 Main Branch
run: git fetch origin main

- name: Merge Main into ${{ github.event.inputs.release_branch }}
run: |
git merge origin/main --allow-unrelated-histories
# Check if there are changes to commit after the merge
if [ -n "$(git status --porcelain)" ]; then
echo "Merging main into ${{ github.event.inputs.release_branch }} branch created changes, committing them."
git add .
git commit -m "Merge main into ${{ github.event.inputs.release_branch }}"
git push
else
echo "No changes to commit after merging main."
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: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/requirements/shared.txt
pip install -r scripts/requirements/databases.txt
pip install -r scripts/requirements/support.txt
sudo apt-get install p7zip-full
- name: Upload new database asset
run: |
python -u scripts/update_db_for_release.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ secrets.PROG_DEBUG_CODEGRIP }} ${{ secrets.PROG_DEBUG_MIKROPROG }} ${{ github.event.inputs.release_version }} "latest"
- name: Commit and Push Changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Updating with new CHANGELOG.md";
git add necto_db_dev.db
git commit -m "Updated necto 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: Upload MCUs Asset
env:
DB_PATH: ${{ secrets.DB_PATH }}
ES_HOST: ${{ secrets.ES_HOST }}
ES_USER: ${{ secrets.ES_USER }}
ES_PASSWORD: ${{ secrets.ES_PASSWORD }}
ES_INDEX: ${{ secrets.ES_INDEX_LIVE }}
ES_INDEX_LIVE: ${{ secrets.ES_INDEX_LIVE }}
run: python -u scripts/release_mcus.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.release.tag_name }}

- name: Run Index Script
env:
ES_HOST: ${{ secrets.ES_HOST }}
ES_USER: ${{ secrets.ES_USER }}
ES_PASSWORD: ${{ secrets.ES_PASSWORD }}
run: |
echo "Indexing to Test."
python -u scripts/index.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.ES_INDEX_TEST }} ${{ github.event.inputs.force_index }} ${{ github.event.inputs.release_version }} "False" "False"
Loading

0 comments on commit bd6902d

Please sign in to comment.