Github 操作问题 - 错误:进程已完成,退出代码 2
我有以下 github 操作的代码:
name: Python application
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: /
python -m pip install --upgrade pip
python -m pip install numpy pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test Selenium
run: /
python -m pytest -v -m devs
但是当我提交并且操作开始运行时,我收到此错误:
Run / python -m pip install --upgrade pip python -m pip install numpy pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
/ python -m pip install --upgrade pip python -m pip install numpy pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
shell: /usr/bin/bash -e {0}
/home/runner/work/_temp/317511f5-0874-43d8-a0ae-2601804ff811.sh: line 1: syntax error near unexpected token `then'
Error: Process completed with exit code 2.
这就在我的安装依赖项下。我错过了一些非常明显的东西吗?预先感谢您的帮助。
I have following piece of code for github actions:
name: Python application
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: /
python -m pip install --upgrade pip
python -m pip install numpy pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test Selenium
run: /
python -m pytest -v -m devs
But when I commit, and actions start running, I get this error:
Run / python -m pip install --upgrade pip python -m pip install numpy pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
/ python -m pip install --upgrade pip python -m pip install numpy pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
shell: /usr/bin/bash -e {0}
/home/runner/work/_temp/317511f5-0874-43d8-a0ae-2601804ff811.sh: line 1: syntax error near unexpected token `then'
Error: Process completed with exit code 2.
And this is just under my Install dependencies. Am I missing something super obvious? Thank you in advance for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的 - 你有一个简单的错误:)
要在
run
下使用多个命令,你必须使用:run: |
而不是\
\
稍后用于将一个 bash 命令分成多行Yes - you have a simple mistake there :)
To have multiple commands under
run
you have to use:run: |
not\
\
is used later on to have one bash command split into multiple lines