Skip to content

True pit (#241)

True pit (#241) #170

name: CI - Upload config.h to API
on:
push:
branches:
- 'master'
paths:
- 'configs/**'
jobs:
deploy:
name: Create or Update Target
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: files
uses: tj-actions/changed-files@v34
with:
files: |
configs/**
- if: steps.files.outputs.any_changed == 'true'
name: Upload configuration
env:
API_KEY: ${{secrets.API_KEY}}
URL: https://build.betaflight.com/api/config
run: |
for target_config in ${{ steps.files.outputs.all_changed_files }}; do
if [[ $target_config == */config.h ]]; then
BOARD_NAME=$(sed -n 's/^.*[[:space:]]BOARD_NAME \([^#]\+\).*$/\1/p' ${target_config} | sed -e 's/[[:space:]]*$//')
STATUS_RECEIVED=$(curl -s --write-out "%{http_code}\n" -X POST -H "Content-Type: text/plain; charset=utf-8" -H "API_KEY: ${API_KEY}" --data-binary @${target_config} ${URL} --silent);
echo "${BOARD_NAME} --> ${STATUS_RECEIVED}"
if [ $STATUS_RECEIVED -ne "200" ]; then
echo "Configuration upload not successful (${BOARD_NAME}) for target configuration ${target_config}."
exit 1
fi
fi
done