Skip to content

Commit

Permalink
fix(ci): Refactor prepare variable step
Browse files Browse the repository at this point in the history
* Refactor workflow variables
* Use quotes to avoid word splitting
  • Loading branch information
filterpaper authored May 17, 2023
1 parent a1e0607 commit b1ca919
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions .github/workflows/build-user-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:

- name: Fetch Build Matrix
run: |
echo "build_matrix=$(yaml2json ${{ inputs.build_matrix_path }} | jq -c .)" >> $GITHUB_ENV
yaml2json ${{ inputs.build_matrix_path }} | jq
echo "build_matrix=$(yaml2json '${{ inputs.build_matrix_path }}' | jq -c .)" >> $GITHUB_ENV
yaml2json "${{ inputs.build_matrix_path }}" | jq
build:
runs-on: ubuntu-latest
Expand All @@ -54,18 +54,13 @@ jobs:
steps:
- name: Prepare variables
shell: sh -x {0}
env:
shield: ${{ matrix.shield }}
run: |
if [ -n "${{ matrix.shield }}" ]
then
echo "extra_cmake_args=-DSHIELD=\"${{ matrix.shield }}\"" >> $GITHUB_ENV
echo "artifact_name=${{ matrix.shield }}-${{ matrix.board }}-zmk" >> $GITHUB_ENV
echo "display_name=${{ matrix.shield }} - ${{ matrix.board }}" >> $GITHUB_ENV
else
echo "extra_cmake_args=" >> $GITHUB_ENV
echo "artifact_name=${{ matrix.board }}-zmk" >> $GITHUB_ENV
echo "display_name=${{ matrix.board }}" >> $GITHUB_ENV
fi
echo "zephyr_version=${ZEPHYR_VERSION}" >> $GITHUB_ENV
echo "extra_cmake_args=${shield:+-DSHIELD=\"$shield\"}" >> $GITHUB_ENV
echo "display_name=${shield:+$shield - }${{ matrix.board }}" >> $GITHUB_ENV
echo "artifact_name=${shield:+$shield-}${{ matrix.board }}-zmk" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -89,7 +84,7 @@ jobs:
${{ runner.os }}-
- name: West Init
run: west init -l ${{ inputs.config_path }}
run: west init -l "${{ inputs.config_path }}"

- name: West Update
run: west update
Expand All @@ -99,7 +94,7 @@ jobs:

- name: West Build (${{ env.display_name }})
shell: sh -x {0}
run: west build -s zmk/app -b ${{ matrix.board }} -- -DZMK_CONFIG=${GITHUB_WORKSPACE}/${{ inputs.config_path }} ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }}
run: west build -s zmk/app -b "${{ matrix.board }}" -- -DZMK_CONFIG="${GITHUB_WORKSPACE}/${{ inputs.config_path }}" ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }}

- name: ${{ env.display_name }} Kconfig file
run: grep -v -e "^#" -e "^$" build/zephyr/.config | sort
Expand All @@ -113,7 +108,7 @@ jobs:
cp build/zephyr/zmk.uf2 "build/artifacts/${{ env.artifact_name }}.uf2"
elif [ -f build/zephyr/zmk.${{ inputs.fallback_binary }} ]
then
cp build/zephyr/zmk.${{ inputs.fallback_binary }} "build/artifacts/${{ env.artifact_name }}.${{ inputs.fallback_binary }}"
cp "build/zephyr/zmk.${{ inputs.fallback_binary }}" "build/artifacts/${{ env.artifact_name }}.${{ inputs.fallback_binary }}"
fi
- name: Archive (${{ env.display_name }})
Expand Down

0 comments on commit b1ca919

Please sign in to comment.