Docker 容器卷未安装在 GitHub 操作中

Docker container volume does not get mounted in GitHub Actions

以下是我的动作文件。

name: ZAP
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: owasp/zap2docker-stable
      options: --user root
      volumes:
        - /__w/actions-test-repo/actions-test-repo:/zap/wrk/
    steps:
      - uses: actions/checkout@v1
      - name: view file
        run: pwd
      - name: run zap
        if: always()
        run: zap-baseline.py -t https://www.example.com -g gen.conf -r testreport.html
      - name: view file
        if: always()
        run: pwd

我想将目录 /zap/wrk/ 绑定到本地目录。但是当容器启动时它不会挂载这个卷。我得到了当前的工作目录并将其安装到 docker 容器中。这是正确的做法吗?

结果link:https://github.com/sshniro/actions-test-repo/commit/08c0257d92b772a1d33c0b68cb8af99afdef9130/checks?check_suite_id=324032091

此论坛中也发现了类似的问题。 https://github.community/t5/GitHub-Actions/Container-volumes-key-not-mounting-volume/td-p/34798

解决方法是使用选项参数。

name: ZAP
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: owasp/zap2docker-stable
      options: -v /__w/actions-test-repo/actions-test-repo:/zap/wrk/:rw
    steps:
      - uses: actions/checkout@v2
      - name: run zap
        if: always()
        run: zap-baseline.py -t https://www.example.com -g gen.conf -w testreport.md