【问题标题】:Github Actions: How to create multiline env variable for serveral jobsGithub Actions:如何为多个作业创建多行环境变量
【发布时间】:2020-05-02 14:18:26
【问题描述】:

我想在代码文件中添加几行。这在各种工作中。所以我创建了一个创建文本文件并上传的作业。

create_file:
  runs-on: ubuntu-latest
  steps:      
    - shell: bash
      run: |
        cat << EOF > data.txt
        A = "..."
        B = "..."
        C = "..."
        ...
        EOF
    - name: Create data file
      uses: actions/upload-artifact@1
      with:
        name: configuration
        path: data.txt

在下一项工作中,我上传了文件并希望将此行附加到代码文件中。

test_file:
  runs-on: ubuntu-latest
  needs: [create_file]
  steps:
  - name: Download file     
    uses: actions/download-artifact@v1
    with:
      name: configuration
      path: configuration/data.txt
  - shell: bash
     run: |
       cat configuration/data.txt >> main.py
       python main.py

我的问题是第二个作业太快了,在 data.txt 文件已经上传之前搜索它,以及如何处理附加内容。每行的命令echo "..." &gt;&gt; main.py 会很烦人。

更新: 现在我得到了工作data.txt 以下错误消息:

 Download action repository 'actions/upload-artifact@1'
 ##[warning]Failed to download action 'https://api.github.com/repos/actions/upload-artifact/tarball/1'. Error Response status code does not indicate success: 404 (Not Found).
 ...
 ##[error]Response status code does not indicate success: 404 (Not Found).

【问题讨论】:

  • 那么希望两个作业并行执行,但第二个在第一个之后完成?否则,您可以将needs create_file 添加到test_file 作业。见:help.github.com/en/actions/…
  • 你解决了吗?
  • @МихаилПавлов 遗憾的是没有。
  • @ikreb 我有一个。使用tr 的壳管。 echo ${{secrets.DATA}} | tr ' ' '\n'

标签: github continuous-integration yaml github-actions


【解决方案1】:

这个错误非常愚蠢。 actions/upload-artifact@1 应该是 actions/upload-artifact@v1

【讨论】:

    猜你喜欢
    • 2022-11-11
    • 2020-04-20
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-20
    • 2020-02-14
    • 2022-10-23
    相关资源
    最近更新 更多