我想將我的一個 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
然而,我嘗試了很多小時用不同的方法將二進制內容復制到 Github Secret,但都失敗了。我試過了pbcopy,,,less。cat有誰知道如何在 github 操作中通過 Github Secret 撰寫二進制檔案?還是更好的解決方案?
謝謝!
uj5u.com熱心網友回復:
(擴展我的評論):
用于base64將二進制字串編碼為文本并將其解碼回二進制。這是相當標準的把戲。
首先,在家編碼:
echo "$MY_BINARY_SECRET" | base64 --wrap=0 > secret.b64
--wrap=0使輸出文本變成一長行;下面有用echo。
將文本檔案secret.b64作為密碼上傳到 GitHub。使用解碼它
echo -n "${{ secrets.MY_BINARY_SECRET }}" | base64 --decode > binary.file
忠告:先嘗試在本地解碼,并與原始字串進行比較。必須是一樣的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/418229.html
標籤:
