当前位置: 首页 > java >正文

【github-action 如何为github action设置secrets/environment】

Using secrets in GitHub Actions

在 GitHub Actions 中使用密钥
Learn how to create secrets at the repository, environment, and organization levels for GitHub Actions workflows.
学习如何在仓库、环境和组织级别为 GitHub Actions 工作流创建密钥。

Creating secrets for a repository为仓库创建密钥

To create secrets or variables on GitHub for a personal account repository, you must be the repository owner. To create secrets or variables on GitHub for an organization repository, you must have admin access. Lastly, to create secrets or variables for a personal account repository or an organization repository through the REST API, you must have collaborator access.
要在 GitHub 上为个人账户仓库创建密钥或变量,您必须是该仓库的所有者。要在 GitHub 上为组织仓库创建密钥或变量,您必须具有 admin 访问权限。最后,要通过 REST API 为个人账户仓库或组织仓库创建密钥或变量,您必须具有协作者访问权限。

  1. On GitHub, navigate to the main page of the repository.
    在 GitHub 上,导航到存储库的主页面。

  2. Under your repository name, click Settings. If you cannot see the “Settings” tab, select the dropdown menu, then click Settings.
    在您的存储库名称下方,点击 设置 。如果您看不到“设置”选项卡,请选择下拉菜单,然后点击 设置

  3. Screenshot of a repository header showing the tabs. The “Settings” tab is highlighted by a dark orange outline.
    In the “Security” section of the sidebar, select Secrets and variables, then click Actions.
    在侧边栏的"安全"部分,选择机密和变量 ,然后点击操作 。

  4. Click the Secrets tab.
    点击 Secrets 标签。

  5. Screenshot of the “Actions secrets and variables” page. The “Secrets” tab is outlined in dark orange.
    Click New repository secret.
    点击 新建仓库密钥

    In the Name field, type a name for your secret.
    名称字段中,输入您的密钥的名称。

    In the Secret field, enter the value for your secret.
    密钥字段中,输入您的密钥的值。

  6. Click Add secret.
    点击 添加密钥

If your repository has environment secrets or can access secrets from the parent organization, then those secrets are also listed on this page.
如果您的仓库有环境密钥或可以访问父组织的密钥,那么这些密钥也会列在此页面上。

Creating secrets for an environment

为环境创建密钥
To create secrets or variables for an environment in a personal account repository, you must be the repository owner. To create secrets or variables for an environment in an organization repository, you must have admin access. For more information on environments, see Managing environments for deployment.
要在个人账户存储库中为环境创建密钥或变量,您必须是存储库的所有者。要在组织存储库中为环境创建密钥或变量,您必须具有 admin 访问权限。有关环境的更多信息,请参阅 管理部署的环境 。

  1. On GitHub, navigate to the main page of the repository.
    在 GitHub 上,导航到存储库的主页面。

  2. Under your repository name, click Settings. If you cannot see the “Settings” tab, select the dropdown menu, then click Settings.
    在您的存储库名称下方,点击 设置 。如果您看不到“设置”选项卡,请选择下拉菜单,然后点击 设置

  3. Screenshot of a repository header showing the tabs. The “Settings” tab is highlighted by a dark orange outline.
    In the left sidebar, click Environments.
    在左侧边栏中,点击 环境

  4. Click on the environment that you want to add a secret to.
    点击您要添加密钥的环境。

  5. Under Environment secrets, click Add secret.
    环境密钥 下,点击 添加密钥

  6. Type a name for your secret in the Name input box.
    在名称输入框中输入您的机密名称。

  7. Enter the value for your secret.
    输入您的密钥值。

  8. Click Add secret.
    点击 添加密钥 。

剩余的查看官方文档

https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets

http://www.xdnf.cn/news/18152.html

相关文章:

  • SpringAI集成MCP
  • (Arxiv-2025)OPENS2V-NEXUS:一个面向主体到视频生成的详细基准与百万规模数据集
  • 【完整源码+数据集+部署教程】织物缺陷检测系统源码和数据集:改进yolo11-RevCol
  • [数据结构] ArrayList 与 顺序表
  • 【前端进阶】UI渲染优化 - 骨架屏技术详解与多框架实现方案
  • RH134 管理网络安全知识点
  • CMake指令:查找文件(find_file)、查找目录(find_path)、查找库文件(find_library)
  • ANSI终端色彩控制知识散播(I):语法封装(Python)——《彩色终端》诗评
  • 图论Day5学习心得
  • 【运维进阶】LNMP + WordPress 自动化部署实验
  • 《Image Classification with Classic and Deep Learning Techniques》复现
  • [Code Analysis] docs | Web应用前端
  • 深度学习-计算机视觉-微调 Fine-tune
  • 学习游戏制作记录(各种独特物品效果)8.18
  • 机器学习-决策树:从原理到实战的机器学习入门指南
  • AI大模型实战:用自然语言处理技术高效处理日常琐事
  • 嵌入式设备Lwip协议栈实现功能
  • 【软考架构】第4章 密钥管理技术和访问控制及数字签名技术
  • 【前端】使用Vue3过程中遇到加载无效设置点击方法提示不存在的情况,原来是少加了一个属性
  • 【大模型】RAG
  • 8.19 note
  • 云原生俱乐部-mysql知识点归纳(1)
  • cesium中实时获取鼠标精确坐标和高度
  • Vue深入组件:组件事件详解1
  • Laravel中如何使用php-casbin
  • OSCP - Proving Grounds - Vanity
  • 云计算核心技术之容器技术
  • SAP 数据脱敏工具:SNP TDO如何满足新颁敏感信息政策要求
  • 【C语言篇】操作符详解
  • 电子电气架构 --- 软件开发数字化转型