我正在尝试将Disponabot与AWS CodeArtifact一起使用,并且我一直在遇到身份验证问题。
depentabot无法对私人软件包注册表进行身份验证
使用了以下专用软件包注册表并导致更新失败:### - ###。d.codeartifact..amazonaws.com/npm/private。
日志:
代理| 2022/06/29 16:52:05 [022]获取https://###-###
代理| 2022/06/29 16:52:06 [022] 401 https://###-###
代理| 2022/06/29 16:52:06 [024]获取https://##-#-###
代理| 2022/06/29 16:52:06 [024] 401 https://###-###
更新程序| info< job_408163671>更新Hermes-engine时处理错误:Private_source_authentication_failure {:source =>“ ### - ###。d.codeartifact。###。
更新Hermes-engine的处理错误:Private_source_authentication_failure {:source =&gt ; > disterabot.yml 配置,例如带有路径的完整codeartifact url或使用令牌
而不是用户名和密码。
我的 distrabot.yml
:
version: 2
registries:
npm-codeartifact:
type: npm-registry
url: https://<registry>-<account>.d.codeartifact.<region>.amazonaws.com
username: aws
password: ${{secrets.CODEARTIFACT_TOKEN}}
- package-ecosystem: "npm"
schedule:
interval: "daily"
registries:
- npm-codeartifact
我应该使用什么来使Displionabot与CodeArtifact一起使用?
I'm trying to use Dependabot with AWS CodeArtifact and I keep getting authentication issues.
Dependabot can't authenticate to a private package registry
The following private package registry was used and caused the update to fail: ###-###.d.codeartifact..amazonaws.com/npm/private.
Logs:
proxy | 2022/06/29 16:52:05 [022] GET https://###-###.d.codeartifact.###.amazonaws.com:443/npm/private/hermes-engine
proxy | 2022/06/29 16:52:06 [022] 401 https://###-###.d.codeartifact.###.amazonaws.com:443/npm/private/hermes-engine
proxy | 2022/06/29 16:52:06 [024] GET https://###-###.d.codeartifact.###.amazonaws.com:443/npm/private/hermes-engine
proxy | 2022/06/29 16:52:06 [024] 401 https://###-###.d.codeartifact.###.amazonaws.com:443/npm/private/hermes-engine
updater | INFO <job_408163671> Handled error whilst updating hermes-engine: private_source_authentication_failure {:source=>"###-###.d.codeartifact.###.amazonaws.com/npm/private"}
I've tried playing with different dependabot.yml
configs, such as full CodeArtifact URL with path or using token
instead of username and password.
My dependabot.yml
:
version: 2
registries:
npm-codeartifact:
type: npm-registry
url: https://<registry>-<account>.d.codeartifact.<region>.amazonaws.com
username: aws
password: ${{secrets.CODEARTIFACT_TOKEN}}
- package-ecosystem: "npm"
schedule:
interval: "daily"
registries:
- npm-codeartifact
What should I be using to make dependabot work with CodeArtifact?
发布评论
评论(3)
此答案基于 @AphexLog 答案和 @andrea de luisi 关于的评论如何更新代码伪影代币,因为它在12个小时后过期。我的解决方案使用Nuget Package Manager作为示例,并使用单独的GitHub Action(.yml File),该操作运行了与Depentabot配置分开的Cron-Job。
precousites
yourProject/.github/disterabot.yml
要创建您的 pat (classic)获得您的个人帐户设置,请向下滚动,直到看到
&lt;&gt;开发人员设置
,然后转到个人访问令牌下拉列表,然后选择令牌(经典)。生成一个新的令牌,并确保点击生成新的令牌(经典)。单击工作流程范围(如果您不属于组织,这将迫使回购范围)。如果您确实属于组织,请单击管理:org范围选项1
选项2
我创建了我的秘密,作为一个依赖性组织的秘密,带有名称code_artifact_token_private_repos,并且仅适用于私人存储库。我的最初值是虚拟值“
”
测试 工作流并设置一个cron-job,每10个小时自动在github操作上运行,
创建一个在Ubuntu上运行的作业。以一种格式创建环境变量,该变量将由 aws cli 和 gh cli(github)自动使用,该变量安装在GitHub Action Runner上。我将codeartifact_auth_token导出为当前外壳的变量,将在以后的步骤中使用。该变量获得适当的codeartifact令牌。 替换-Domain FullstackIndie-Domain所有者896630178141带有您的AWS CodeArtifact帐户信息。
这最后一步使用Github Cli到 set 创建的依赖性依赖>较早的回购或组织。您可以为。您还必须插入包含令牌的 - 身体 arg。使用环境变量时,您必须使用“ $ MY_ENV”格式进行 - 身体。因为我的依赖性组织的秘密仅适用于私人存储库有效,所以我将其视为私人。我还使用 - org flag 来改变我的依赖机构组织的秘密。如果使用Disperabot存储库秘密,那么您的令牌看起来与此相似,
我建议我建议通过转到存储库中的“操作”选项卡,单击工作流,然后在下拉列表中单击“运行工作流”。如果没有,您的存储库可能不会在第一次运行之前更新10个小时左右
This answer is based off of @aphexlog answer and @Andrea De Luisi comment about how to update the Code Artifact token because it expires after 12 hours. My solution uses Nuget Package Manager as an example and uses a separate GitHub Action (.yml file) that runs a cron-job which is separate from the dependabot configuration.
Prequisites
YourProject/.github/dependabot.yml
YourProject\.github\workflows\aws-code-artifact-updatetoken.yml
To create your PAT (classic) goto your personal account settings, scroll down until you see
<> Developer Settings
, then go to the personal access tokens dropdown and choose Tokens (classic). Generate a new token and make sure to click Generate New Token (classic). Click workflow scope (this will force repo scopes) if you do not belong to an organization. If you do belong to organization, also click admin:org scopeOption 1
Option 2
I have created my secret as a dependabot organization secret with the name CODE_ARTIFACT_TOKEN_PRIVATE_REPOS and it is only accessible to private repositories. My initial value was a dummy value "test" because it was going to get run and updated to a proper token after the workflow is run
aws-code-artifact-updatetoken.yml
This creates a name for the workflow and sets up a cron-job to run on GitHub Actions automatically every 10 hours
Create a job that runs on ubuntu. Creates environment variables in a format that will be used automatically by the aws cli and gh cli (github) that comes installed on the GitHub Action runner. I am exporting CODEARTIFACT_AUTH_TOKEN as a variable to the current shell to be used in a later step. This variable gets a proper CodeArtifact token. Replace --domain fullstackindie --domain-owner 896630178141 with your AWS CodeArtifact account information.
This last step uses the github cli to set the Dependabot Repository/Organization secret that was created earlier for your repo or organization. You can set different flags/args for the gh secret set but You have to include the --app dependabot to update Dependabot secrets. You must also inlcude the --body arg that contains the token. When using environment variables, you have to use "$MY_ENV" format for --body. Because my dependabot organization secret is only valid for private repositories I have put visibility as private. I am also using the --org flag to change my Dependabot Organization secret. If using a Dependabot Repository secret then your token will look similar to this
I would recommend forcing a workflow run by going to the "Actions" tab in your repo, click on the workflow and then click "run workflow" in the dropdown. If not, your repo might not update the token for 10 hours or so before the first run
@aphexlog错过了一个关键点,使依赖动枪与诗歌一起工作。
您需要在令牌值之前添加添加 aws: 。
@aphexlog missed one key point to make dependabot work with poetry.
You need to add add aws: before the token value.
如果您使用的是代币,则无需指定用户名:
If you are using tokens, you don't need to specify a username: