github操作docker找不到文件

34gzjxbg  于 2021-06-09  发布在  Cassandra
关注(0)|答案(1)|浏览(405)

我有一个非常简单的项目: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 因为ls返回 setup.cql :

如何在github操作中的docker中运行.cql脚本

g9icjywg

g9icjywg1#

您的服务无权访问本地文件。确保创建一个卷,然后您就可以运行您的命令。下面的解决方案假设文件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

相关问题