Github 操作 Docker 找不到文件
Github Actions Docker can't find file
我有这个非常简单的项目:https://github.com/Jasperav/cas_docker。我想在我的 docker 容器中执行 setup.cql (虽然是空的)。这是我的 yml 文件:
name: tests-cassandra
on: push
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
services:
cassandra:
image: cassandra
ports:
- 9042:9042
options: --health-cmd "cqlsh --debug" --health-interval 5s --health-retries 10
steps:
- uses: actions/checkout@v2
- run: |
ls
docker exec -i ${{ job.services.cassandra.id }} cqlsh -f setup.cql
Docker 能够在 运行 执行 docker exec
命令之前看到 setup.cql 在当前目录中,因为 ls returns setup.cql
:
如何在 Github 操作 运行 中 Docker 中的 .cql 脚本
您的服务无权访问本地文件。确保创建一个卷,然后您将能够 运行 您的命令。以下解决方案假设文件 setup.cql 存在于您的 repo 目录
的根目录中
回购结构假设
repo/
.github/workflows/your-worflow.yaml
setup.cql
... any other files/dirs
工作流更新
services:
cassandra:
image: cassandra
ports:
- 9042:9042
options: --health-cmd "cqlsh --debug" --health-interval 5s --health-retries 10
volumes:
- ${{ github.workspace }}:/workspace
steps:
- uses: actions/checkout@v2
- run: docker exec -i ${{ job.services.cassandra.id }} cqlsh -f /workspace/setup.cql
我有这个非常简单的项目:https://github.com/Jasperav/cas_docker。我想在我的 docker 容器中执行 setup.cql (虽然是空的)。这是我的 yml 文件:
name: tests-cassandra
on: push
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
services:
cassandra:
image: cassandra
ports:
- 9042:9042
options: --health-cmd "cqlsh --debug" --health-interval 5s --health-retries 10
steps:
- uses: actions/checkout@v2
- run: |
ls
docker exec -i ${{ job.services.cassandra.id }} cqlsh -f setup.cql
Docker 能够在 运行 执行 docker exec
命令之前看到 setup.cql 在当前目录中,因为 ls returns setup.cql
:
如何在 Github 操作 运行 中 Docker 中的 .cql 脚本
您的服务无权访问本地文件。确保创建一个卷,然后您将能够 运行 您的命令。以下解决方案假设文件 setup.cql 存在于您的 repo 目录
的根目录中回购结构假设
repo/
.github/workflows/your-worflow.yaml
setup.cql
... any other files/dirs
工作流更新
services:
cassandra:
image: cassandra
ports:
- 9042:9042
options: --health-cmd "cqlsh --debug" --health-interval 5s --health-retries 10
volumes:
- ${{ github.workspace }}:/workspace
steps:
- uses: actions/checkout@v2
- run: docker exec -i ${{ job.services.cassandra.id }} cqlsh -f /workspace/setup.cql