Travis-ci解密加密文件

问题描述 投票:4回答:2

我加密了我的.env文件,现在我有一个.env.enc文件。我的团队如何解密这个?我加密文件时得到了这个响应,它存储在我的.travis.yml文件中

openssl aes-256-cbc -K $encrypted_cf94abc85bdc_key -iv $encrypted_cf94abc85bdc_iv -in .env.enc -out .env -d

我在终端上尝试了这个,我得到:

iv undefined

我尝试用travis-cli解密:

travis encrypt-file .env.enc .env -d 

我得到这个:

key must be 64 characters long and a valid hex number

我用钥匙和iv试了一下

travis encrypt-file .env.enc .env -d -K $encrypted_cf94abc85bdc_key -iv $encrypted_cf94abc85bdc_iv

我检查了travis env变量是否存在,它们是这样做的:

encrypted_cf94abc85bdc_key=[secure]
encrypted_cf94abc85bdc_iv=[secure]
continuous-integration travis-ci
2个回答
0
投票

您的文件可能在Travis构建期间的某处解密。将deploy步骤添加到构建中可能是最简单的,因此将.env文件上载到您可以自己下载的地方。

有关如何部署文件的详细信息,请查看this link或此one specifically for github

这是我所做的简短示例;)

.travis.yml

before_install:
  // Somewhere your files are being decrypted 
  openssl aes-256-cbc -K $encrypted_cf94abc85bdc_key -iv $encrypted_cf94abc85bdc_iv -in .env.enc -out .env -d

// Add a deploy step, which allows you which files to upload
deploy:
  file: 
  - .env  /* add the file here, so it will be pushed to github */
  api_key: $apikey
  on:
    repo: <your github repo>

0
投票

检查travis encrypt-file的输出!

特别是第一行:

encrypting <filename> for <repository name>
[..]

您需要使用正确的仓库(并在需要时使用--com)以确保Travis能够找到以后需要的生成值。

© www.soinside.com 2019 - 2024. All rights reserved.