GitHub Actions には少し特殊なワークフローコマンドというものがあります。実態はecho
コマンドですが、出力の形式が決められてます。
ワークフローコマンドには以下のような種類があります。
set-env
set-output
add-path
error
warning
debug
add-mask
set-env
jobs:
build:
steps:
# `echo nju33`は動的な情報入力のつもり
- run: echo nju33 | xargs -I{} echo "::set-env name=NAME::{}"
- run: echo "$NAME"
<job-id>.env
<job-id>.steps.<step-id>.env
jobs:
build:
env:
FOO: foo
steps:
- run: ...
env:
BAR: bar
steps.<step-id>.outputs.<value-name>
<step-id>
id
jobs:
build:
steps:
- id: org
run: echo "::set-output name=name::nju33-com"
- run: echo "${{ steps.org.outputs.name }}"
run: echo "${{ steps.org.outputs.name }}"
nju33-com
set-output
repository
jobs:
build:
steps:
- id: org
run: echo "::set-output name=name::nju33-com"
- run: echo "${{ steps.org.outputs.name }}"
- id: repo
run: echo "::set-output name=name::${{ steps.org.outputs.name }}/sandbox-github-actions-workflow-command"
- uses: actions/checkout@v2
with:
repository: ${{ steps.repo.outputs.name }}
repository
nju33-com/sandbox-github-actions-workflow-command
actions/checkout
PATH
cowsay
npm
yarn
node_modules/.bin
cowsay
node_modules/.bin/cowsay
cowsay
PATH
jobs:
build:
steps:
- run: |
yarn init -y
yarn add -D cowsay
- run: |
if command -v cowsay > /dev/null; then
cowsay Moo
else
echo cowsay: command not found
fi
- run: echo "::add-path::$(pwd)/node_modules/.bin"
- run: |
if command -v cowsay > /dev/null; then
cowsay Moo
else
echo cowsay: command not found
fi
cowsay
cowsay
PATH
Moo
cowsay: command not found
add-path
$(pwd)/node_modules/.bin
cowsay
Moo
_____
< Moo >
-----
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
jobs:
build:
steps:
- run: echo ::error::error-message
file
line
col
,
jobs:
build:
steps:
- run: |
echo ::error file=index.js,line=1,col=1::The first line is bad
exit 1
- run: echo foo
error
jobs:
build:
runs-on: ubuntu-16.04
steps:
- run: echo ::warning::warning-message
- run: echo ::warning file=.github/workflows/warning.yml,line=10,col=14::ubuntu-18.04 使ってね
ACTIONS_STEP_DEBUG
true
echo 123
##[debug]Evaluating condition for step: 'Run echo 123'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run echo 123
##[debug]Loading inputs
##[debug]Loading env
Run echo 123
##[debug]/bin/bash -e /home/runner/work/_temp/b85ddda2-9c07-4f5d-80c2-f0b6b46fc9a8.sh
123
##[debug]Finishing: Run echo 123
debug
debug-message
jobs:
build:
steps:
- run: echo ::debug::debug-message
debug
ACTIONS_STEP_DEBUG
true
***
jobs:
build:
steps:
- run: echo ::add-mask::foo
::add-mask::***