appctl(gcloud 组件)在哪里寻找 git 访问令牌或 ssh 密钥?
Where does appctl (gcloud component) look for git access token or ssh keys?
我目前正在 GitHub 操作中使用 appctl
部署到 GKE。
通过一些工作,我也能够成功安装 gcloud sdk 和 appctl。
(因为默认 GitHub 运行ner 从 apt 安装 cloud sdk,我无法从该发行版安装单独的组件)
我运行正在执行以下操作以初始化我的配置存储库:
- name: 'Configuring ssh key'
run: |-
cd ${HOME}
mkdir ${HOME}/.ssh
gcloud secrets versions access latest --secret="my-ssh-key" --project=${{secrets.GCLOUD_PROJECT_ID}} > ${HOME}/.ssh/id_rsa
chmod 600 ${HOME}/.ssh/id_rsa
ssh-add ${HOME}/.ssh/id_rsa
- run: export APPCTL_INTERACTIVE=false
- name: 'Initializing git repo'
run: |-
appctl init my-app --app-config-repo=https://github.com/ORG/my-app-config
#other operations....
git add .
git commit -m "Updated config for latest develop commit $GITHUB_SHA"
git tag $(git rev-parse --short HEAD)
git push origin --tags
以上内容在初始化我的存储库时有效,甚至标记和推送也按预期工作,这让我相信它使用我的 ssh 密钥对我的配置存储库进行身份验证,因为它是私有的。
但是在调用 appctl prepare dev
时我首先得到了一些好东西:
Sync-up the latest Refs from remote ...
Generating kustomize artifacts...
Stash deployment git repo...
Writing release artifact to deployment repo...
Pushing the new git-commit to the deployment repo.
然后我运行进入这个。
Error: unable to find personal token. Please consider setting the environment variable "APPCTL_INTERACTIVE" to be true
现在奇怪的是所有推送等都按预期工作。唯一就是好像appctl
不能创建PR?它将标签和所有内容推送到配置 and 部署回购协议。
还有其他人遇到类似问题吗?就推送标签等而言,我得到了我需要的一切,但由于访问令牌,工作失败了。如果我的原始 ssh 密钥在检查配置存储库时有效,甚至推送标签并提交到遥控器,最后一步 appctl
试图做的是需要访问令牌,我将把它添加到 CI/CD管道?
如有任何帮助,我们将不胜感激。
经过几个小时的寻找和尝试不同的事情,我已经解决了我的问题。
我发现当 appctl
要求您提供 GitHub 访问令牌(它用于代表您创建合并请求)时,它会将其存储在主目录中的一个文件下叫做 .appctlconfig
所以位置将是 ~/.appctlconfig
,我通过观察 Mac 上的文件系统发现了这一点,只是注意到正在发生的事情 read/accessed.
那个文件的格式是(你猜对了)K8s 类型
apiVersion: appctl.gke.io/v1beta1
creationTimestamp: null
github_access_token: my-access-token
kind: Config
我的解决方案是模仿该格式,并在我调用 appctl prepare dev
之前将其写入正确的路径
${{secrets.APPCTL_CONFIG}} > ${HOME}/.appctlconfig
appctl
对此很满意,并成功地代表我创建了一个 PR。
我目前正在 GitHub 操作中使用 appctl
部署到 GKE。
通过一些工作,我也能够成功安装 gcloud sdk 和 appctl。 (因为默认 GitHub 运行ner 从 apt 安装 cloud sdk,我无法从该发行版安装单独的组件)
我运行正在执行以下操作以初始化我的配置存储库:
- name: 'Configuring ssh key'
run: |-
cd ${HOME}
mkdir ${HOME}/.ssh
gcloud secrets versions access latest --secret="my-ssh-key" --project=${{secrets.GCLOUD_PROJECT_ID}} > ${HOME}/.ssh/id_rsa
chmod 600 ${HOME}/.ssh/id_rsa
ssh-add ${HOME}/.ssh/id_rsa
- run: export APPCTL_INTERACTIVE=false
- name: 'Initializing git repo'
run: |-
appctl init my-app --app-config-repo=https://github.com/ORG/my-app-config
#other operations....
git add .
git commit -m "Updated config for latest develop commit $GITHUB_SHA"
git tag $(git rev-parse --short HEAD)
git push origin --tags
以上内容在初始化我的存储库时有效,甚至标记和推送也按预期工作,这让我相信它使用我的 ssh 密钥对我的配置存储库进行身份验证,因为它是私有的。
但是在调用 appctl prepare dev
时我首先得到了一些好东西:
Sync-up the latest Refs from remote ...
Generating kustomize artifacts...
Stash deployment git repo...
Writing release artifact to deployment repo...
Pushing the new git-commit to the deployment repo.
然后我运行进入这个。
Error: unable to find personal token. Please consider setting the environment variable "APPCTL_INTERACTIVE" to be true
现在奇怪的是所有推送等都按预期工作。唯一就是好像appctl
不能创建PR?它将标签和所有内容推送到配置 and 部署回购协议。
还有其他人遇到类似问题吗?就推送标签等而言,我得到了我需要的一切,但由于访问令牌,工作失败了。如果我的原始 ssh 密钥在检查配置存储库时有效,甚至推送标签并提交到遥控器,最后一步 appctl
试图做的是需要访问令牌,我将把它添加到 CI/CD管道?
如有任何帮助,我们将不胜感激。
经过几个小时的寻找和尝试不同的事情,我已经解决了我的问题。
我发现当 appctl
要求您提供 GitHub 访问令牌(它用于代表您创建合并请求)时,它会将其存储在主目录中的一个文件下叫做 .appctlconfig
所以位置将是 ~/.appctlconfig
,我通过观察 Mac 上的文件系统发现了这一点,只是注意到正在发生的事情 read/accessed.
那个文件的格式是(你猜对了)K8s 类型
apiVersion: appctl.gke.io/v1beta1
creationTimestamp: null
github_access_token: my-access-token
kind: Config
我的解决方案是模仿该格式,并在我调用 appctl prepare dev
${{secrets.APPCTL_CONFIG}} > ${HOME}/.appctlconfig
appctl
对此很满意,并成功地代表我创建了一个 PR。