如何使用 Github 工作流程的二进制文件设置 Gihub Secret?

Wen*_*liL 7 binary binaryfiles github github-actions

我想将我的 API 配置文件 ( binary.file) 之一添加到 Github 机密 (MY_BINARY_SECRET)。binary.file然后它将在工作流程中再次读取和写入:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install System
        run: |
          sudo apt-get update
          sudo apt-get install -y pip python3.8-venv libcurl4-openssl-dev

      - name: Set up configurations
        shell: bash
        run: |
          echo "${{ secrets.MY_BINARY_SECRET }}" > binary.file
          python3 .... # the python script will need binary.file to complete authentication  
Run Code Online (Sandbox Code Playgroud)

然而,我尝试了很多个小时,用不同的方法将二进制内容复制到 Github Secret,但都失败了。我试过pbcopylesscat。有谁知道如何在 github actions 中通过 Github Secret 编写二进制文件?或者更好的解决方案?

谢谢你!

phd*_*phd 8

(扩展我的评论):

用于base64将二进制字符串编码为文本并将其解码回二进制。这是非常标准的技巧。

首先,在家编码:

echo "$MY_BINARY_SECRET" | base64 --wrap=0 > secret.b64
Run Code Online (Sandbox Code Playgroud)

--wrap=0使输出文本成为一长行;对下面有用echo

将文本文件secret.b64作为秘密上传到 GitHub。使用解码它

echo -n "${{ secrets.MY_BINARY_SECRET }}" | base64 --decode > binary.file
Run Code Online (Sandbox Code Playgroud)

建议:首先尝试本地解码并与原始字符串进行比较。一定是一样的。