Skip to content

Commit 5240d36

Browse files
fix: quote inputs and improve shell conditionals for safety (#68)
This PR improves **safety and consistency** of the GitHub Actions workflow (build-test-images.yml) file by: - Using **[[ ... ]]** **instea**d of **[ ... ]** for conditionals. - Adding **double quotes** around inputs and refs to **avoid** evaluation issues. This helps prevent bugs in **shell parsing**, especially with **empty or misinterpreted** input values. @katiewasnothere @wlan0
1 parent 6216c6e commit 5240d36

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

.github/workflows/build-test-images.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ jobs:
3434
steps:
3535
- name: Check branch
3636
run: |
37-
if [ '${{ github.ref }}' != 'refs/heads/main' ] && [[ '${{ github.ref }}' != refs/heads/release* ]] && [ ${{ inputs.publish }} == true ]; then
38-
echo "Cannot publish an image if we are not on main or a release branch."
37+
if [[ "${{ github.ref }}" != "refs/heads/main" ]] && [[ "${{ github.ref }}" != refs/heads/release* ]] && [[ "${{ inputs.publish }}" == "true" ]]; then
38+
echo "Cannot publish an image if we are not on main or a release branch."
3939
exit 1
4040
fi
4141
- name: Check inputs
4242
run: |
43-
if [ ${{ inputs.image }} == 'dockermanifestimage' ] && [ ${{ inputs.useBuildx }} == true ]; then
44-
echo "dockermanifestimage cannot be built with buildx"
43+
if [[ "${{ inputs.image }}" == "dockermanifestimage" ]] && [[ "${{ inputs.useBuildx }}" == "true" ]]; then
44+
echo "dockermanifestimage cannot be built with buildx"
4545
exit 1
4646
fi
4747
48-
if [ ${{ inputs.image }} == 'emptyimage' ] && [ ${{ inputs.useBuildx}} != true ]; then
49-
echo "emptyimage should be built with buildx"
48+
if [[ "${{ inputs.image }}" == "emptyimage" ]] && [[ "${{ inputs.useBuildx }}" != "true" ]]; then
49+
echo "emptyimage should be built with buildx"
5050
exit 1
5151
fi
5252
- name: Checkout repository

0 commit comments

Comments
 (0)