2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GitHub Actions: InputsのBoolean評価まとめ

Posted at

GitHub ActionsのBoolean

GitHub Actionsにおける特殊なbooleanの評価について、
いつも迷うので下記に一覧表残しておきます。(検索してもfalseに関する評価結果がないものが多いので。)

一覧表

# 評価式 結果
1 true ${{ inputs.boolean == true }} true
2 ❗️ true ${{ inputs.boolean == 'true' }} false
3 ❗️ true ${{ inputs.boolean != 'true' }} true
4 true ${{ inputs.boolean == false }} false
5 true ${{ inputs.boolean == 'false' }} false
6 true ${{ inputs.boolean != 'false' }} true
7 false ${{ inputs.boolean == true }} false
8 false ${{ inputs.boolean == 'true' }} false
9 false ${{ inputs.boolean != 'true' }} true
10 false ${{ inputs.boolean == false }} true
11 ❗️ false ${{ inputs.boolean == 'false' }} false
23 ❗️ false ${{ inputs.boolean != 'false' }} true

shell構文

🙅‍♂️ testによるBooleanの評価

expression
if [ true ]; then
  echo "❗️:true"
elif
  echo "🙆‍♂️:true"
fi

if [ false ]; then
  echo "❗️:false"
elif
  echo "🙆‍♂️:false"
fi
result
🙆‍♂️:true
❗️:false

🙆‍♂️ 直接Booleanの評価

expression
if true; then
  echo "❗️:true"
elif
  echo "🙆‍♂️:true"
fi
if false; then
  echo "❗️:false"
elif
  echo "🙆‍♂️:false"
fi

result
🙆‍♂️:true
🙆‍♂️:false
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?