简体   繁体   English

github 操作中的权限被拒绝错误

[英]Permission denied error in github actions

I have written a github action to retrieve the changed sql files and lint those changed files using sqlfluff.我编写了一个 github 操作来检索更改的 sql 文件并使用 sqlfluff 对这些更改的文件进行 lint。

Here is my github action code:这是我的 github 操作代码:

name: files_lint

on:
  - pull_request

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: Install Python
        uses: "actions/setup-python@v2"
        with:
          python-version: "3.7"
      - name: install sqlfluff
        run: "pip install sqlfluff"

      - name: Get changed .sql files
        id: linting
        run: some code to get the changed files

      - name: Linting files started
        id: sql_linting
        if: steps.linting.outputs.lintees != ''
        shell: bash -l {0}
        run: ${{ steps.linting.outputs.lintees }} > sqlfluff fix --force

But when I run ${{ steps.linting.outputs.lintees }} > sqlfluff fix --force on the changed sql files in the above github action, I'm getting an error但是,当我在上述 github 操作中对更改的 sql 文件运行${{ steps.linting.outputs.lintees }} > sqlfluff fix --force时,我收到错误消息

/home/runner/work/_temp/a41i1c89a4.sh: line 1: test.sql: Permission denied
Error: Process completed with exit code 126.

You can't redirect files like this:您不能像这样重定向文件:


run: ${{ steps.linting.outputs.lintees }} > sqlfluff fix --force

This is attempting to write the output of whatever that command is - but I'd guess it's a list of files rather than a command?这是试图编写该命令的 output - 但我猜它是文件列表而不是命令?

You should pass as parameters (assuming it's a list of files):您应该作为参数传递(假设它是文件列表):


run: sqlfluff fix --force ${{ steps.linting.outputs.lintees }}

Also I presume you're going to do something with it afterwards?另外我想你以后会用它做点什么吗? If not the fixed files who the do anything.如果不是固定文件谁做任何事情。 If you just want to check the files sqlfluff lint would be better than sqlfluff fix .如果您只想检查文件sqlfluff lint会比sqlfluff fix更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM