I integrate STM32CubeProgrammer with github action for deploy.
Although the command exit with error, github action workflow did not fail so that the result is success.
Because the command print "Error" at console log, I just want to grep this and make the workflow fail. how can I do that?
I am using self-hosted runner(Windows 10)
jobs:
build:...
deployment:
# The type of runner that the job will run on
runs-on: [ self-hosted, deploy ]
needs: build
environment: production
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs a set of commands using the runners shell
- name: deploy
run: |
STM32_Programmer_CLI.exe -c port=SWD -w ${{ secrets.ELF_FILE }} ${{ secrets.START_ADDR }}
- name: start
run: |
STM32_Programmer_CLI.exe -c port=SWD -c port=SWD -s ${{ secrets.START_ADDR }}
I save the output and use regular expression using -match
jobs:
build:...
deployment:
# The type of runner that the job will run on
runs-on: [ self-hosted, deploy ]
needs: build
environment: production
outputs:
result: ${{ steps.deploy.outputs.DEPLOY_RESULT }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: deploy
# based on Windows Powershell batch script language
run: |
$deploy_result = $(STM32_Programmer_CLI.exe -c port=SWD -w ${{ env.ELF_FILE }} ${{ env.START_ADDR }})
echo $deploy_result
if ( $deploy_result -match "File download complete" ) {} else { exit 1 }