CORE generation #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow that is manually triggered | |
name: CORE generation | |
# Controls when the action will run. Workflow runs when manually triggered using the UI | |
# or API. | |
on: | |
workflow_dispatch: | |
# Inputs the workflow accepts. | |
inputs: | |
mcu_name: | |
# Name of the MCU for which generation is running | |
description: 'MCU name' | |
# Default value if no value is explicitly provided | |
default: 'mk20dn32vlh5' | |
# Input has to be provided for the workflow to run | |
required: true | |
# The data type of the input | |
type: string | |
vendor: | |
# Vendor of the MCU | |
description: 'Vendor' | |
# Default value if no value is explicitly provided | |
default: 'nxp' | |
# Input has to be provided for the workflow to run | |
required: true | |
# The data type of the input | |
type: string | |
pdfFile: | |
# Path to the reference manual PDF file | |
description: 'Reference manual PDF file path' | |
# Default value if no value is explicitly provided | |
default: '/tmp/documentation/mk20dn32vlh5_rm.pdf' | |
# Input has to be provided for the workflow to run | |
required: true | |
# The data type of the input | |
type: string | |
build_branch: | |
type: string | |
description: Which Branch to build MCUs on? (change last number to desired number) | |
default: "new-feature/automation/1" | |
build_version: | |
type: string | |
description: Tag to use for script run (i.e. v1.0.7) | |
default: "latest" | |
env: | |
NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }} | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "Generate CORE" | |
Generate_Core: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Runs a single command using the runners shell | |
- name: Send greeting | |
run: echo "Starting CORE generation workflow..." | |
# Checkout branch | |
- uses: actions/checkout@v2 | |
- 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: Add GitHub Actions credentials | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
# Create a new branch | |
- name: Create branch | |
run: | | |
git branch ${{ github.event.inputs.build_branch }} | |
git checkout ${{ github.event.inputs.build_branch }} | |
git push -u origin ${{ github.event.inputs.build_branch }} | |
# Create a new directory at the root of your repository | |
- name: Create automatization directory | |
run: mkdir -p automatization | |
- name: See what we downloaded | |
run: ls | |
# Trigger the workflow on the private repository (Assuming the private repository has a workflow that runs on repository_dispatch event) | |
- name: Trigger Workflow on Private Repository | |
env: | |
REPO: "MikroElektronika/sdk_automation" | |
run: | | |
curl -s \ | |
-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/actions/workflows/generate_core.yml/dispatches \ | |
-d '{ | |
"ref": "danilo.milenkovic/main", | |
"inputs": { | |
"mcu_name": "${{ github.event.inputs.mcu_name }}", | |
"vendor": "${{ github.event.inputs.vendor }}", | |
"pdfFile": "${{ github.event.inputs.pdfFile }}" | |
} | |
}' | |
- name: Get run ID | |
id: get_id | |
env: | |
REPO: "MikroElektronika/sdk_automation" | |
run: | | |
while : ; do | |
runID=$(curl -s -H "Authorization: token $TOKEN" \ | |
-H "Accept: application/vnd.github+json" \ | |
"https://api.github.com/repos/$REPO/actions/workflows/generate_core.yml/runs" \ | |
| jq -r '.workflow_runs[0].id') | |
if [[ -z "$runID" ]]; then | |
echo "No in-progress run found yet. Retrying in 10 seconds..." | |
sleep 10 | |
continue | |
fi | |
echo "run_id=$runID" >> $GITHUB_OUTPUT | |
echo "Found in-progress workflow with RUN_ID: $run_id" | |
break | |
done | |
# Wait for the workflow to complete | |
- name: Wait for the Triggered Workflow Finish | |
env: | |
REPO: "MikroElektronika/sdk_automation" | |
run: | | |
while : ; do | |
STATUS=$(curl -s -H "Authorization: Bearer ${{ secrets.MIKROE_ACTIONS_KEY }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
https://api.github.com/repos/$REPO/actions/workflows/generate_core.yml/runs/${{ steps.get_id.outputs.run_id }} \ | |
| jq -r '.status') | |
CONCLUSION=$(curl -s -H "Authorization: Bearer ${{ secrets.MIKROE_ACTIONS_KEY }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
https://api.github.com/repos/$REPO/actions/workflows/generate_core.yml/runs/${{ steps.get_id.outputs.run_id }} \ | |
| jq -r '.conclusion') | |
echo "Workflow status: $STATUS" | |
if [[ "$STATUS" == "completed" ]]; then | |
echo "Workflow completed with conclusion: $CONCLUSION" | |
break | |
fi | |
# Wait for a few seconds before checking again | |
sleep 10 | |
done | |
# Check the conclusion and fail the job if the triggered workflow failed | |
if [[ "$CONCLUSION" != "success" ]]; then | |
echo "Triggered workflow failed with conclusion: $CONCLUSION" | |
exit 1 | |
fi | |
echo "Triggered workflow completed successfully!" | |
- name: Fetch asset | |
run: gh release download --repo MikroElektronika/sdk_automation latest | |
env: | |
GH_TOKEN: ${{ secrets.MIKROE_ACTIONS_KEY }} | |
- name: See what we downloaded | |
run: ls | |
# Commit changes | |
#- name: Commit changes | |
# run: | | |
# git add . | |
# git commit -m "Pulled files from sdk_automation into core_packages" | |
# Push changes back to your repository | |
#- name: Push changes | |
# run: | | |
# git push -u origin ${{ github.event.inputs.build_branch }} |