Github 行动组织秘密更新

时间:2021-01-04 11:34:09

标签: python amazon-web-services github github-actions

我正在处理一个 github 操作,该操作应该轮换组织机密中的 AWS 密钥,但我找不到更新机密的方法。代码:https://github.com/forrasmisii/aws-secret-test

我尝试遵循本指南,但对我没有帮助。 https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-an-organization-secret

def upload_secret(owner_repo,key_name,encrypted_value,pub_key_id,github_token):
    #upload encrypted access key
    updated_secret = requests.put(
        #f'https://api.github.com/orgs/{owner_repo}/actions/secrets/{key_name}',
        f'https://api.github.com/repos/{owner_repo}/actions/secrets/{key_name}',
        # orgs/{org}/actions/secrets/{secret_name}
        json={
            'encrypted_value': encrypted_value,
            'key_id': pub_key_id
        },
        headers={'Authorization': f"token {github_token}"}
    )

我尝试使用这两个命令访问 api:

f'https://api.github.com/orgs/{owner_repo}/actions/secrets/{key_name}'

f'https://api.github.com/repos/{owner_repo}/actions/secrets/{key_name}'

第一个给出错误:Got status code: 404 on updating access_key_id in Company_name/repo_name

第二个创建存储库本地机密,但不是组织机密。

您知道如何更新组织机密而不是回购机密吗?

谢谢

0 个答案:

没有答案