github action

简介: github action


人一辈子都在高潮——低潮中浮沉,唯有庸碌的人,生活才如死水一般。——傅雷

分享一下Github Action的文档:

GitHub Actions 快速入门 - GitHub 文档

GitHub Actions 快速入门

在 5 分钟或更短的时间内尝试 GitHub Actions 的功能。

Introduction  介绍

You only need a GitHub repository to create and run a GitHub Actions workflow. In this guide, you’ll add a workflow that demonstrates some of the essential features of GitHub Actions.

您只需要 GitHub 存储库即可创建和运行 GitHub Actions 工作流程。在本指南中,您将添加一个工作流程来演示 GitHub Actions 的一些基本功能。

The following example shows you how GitHub Actions jobs can be automatically triggered, where they run, and how they can interact with the code in your repository.

以下示例向您展示了如何自动触发 GitHub Actions 作业、它们运行的位置以及它们如何与存储库中的代码进行交互。

[Creating your first workflow

创建您的第一个工作流程](https://docs.github.com/zh/actions/quickstart#creating-your-first-workflow)

  1. Create a .github/workflows directory in your repository on GitHub if this directory does not already exist. The directory must have this exact name in order for GitHub to discover any GitHub Actions workflows that it contains.
    如果此目录尚不存在,请在 GitHub 上的存储库中创建一个 .github/workflows 目录。该目录必须具有此确切名称,GitHub 才能发现它包含的任何 GitHub Actions 工作流程。
  2. In the .github/workflows directory, create a file with the .yml or .yaml extension. This tutorial will use github-actions-demo.yml as the file name. For more information, see “Creating new files.”
    .github/workflows 目录中,创建一个扩展名为 .yml.yaml 的文件。本教程将使用 github-actions-demo.yml 作为文件名。有关详细信息,请参阅“创建新文件”。
  3. Copy the following YAML contents into the github-actions-demo.yml file:
    将以下 YAML 内容复制到 github-actions-demo.yml 文件中:
    YAML
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
 Explore-GitHub-Actions:
   runs-on: ubuntu-latest
   steps:
     - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
     - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
     - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
     - name: Check out repository code
       uses: actions/checkout@v4
     - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
     - run: echo "🖥️ The workflow is now ready to test your code on the runner."
     - name: List files in the repository
       run: |          ls ${{ github.workspace }}
     - run: echo "🍏 This job's status is ${{ job.status }}."
  1. Scroll to the bottom of the page and select Create a new branch for this commit and start a pull request. Then, to create a pull request, click Propose new file.
    滚动到页面底部并选择为此提交创建新分支并启动拉取请求。然后,要创建拉取请求,请单击“提议新文件”。

Committing the workflow file to a branch in your repository triggers the push event and runs your workflow.

将工作流程文件提交到存储库中的分支会触发 push 事件并运行您的工作流程。

[Viewing your workflow results

查看您的工作流程结果](https://docs.github.com/zh/actions/quickstart#viewing-your-workflow-results)

  1. On GitHub.com, navigate to the main page of the repository.
    GitHub.com 上,导航到存储库的主页。
  2. Under your repository name, click  Actions.
    在您的存储库名称下,单击操作。

  3. In the left sidebar, click the workflow you want to display, in this example “GitHub Actions Demo.”
    在左侧边栏中,单击要显示的工作流程,在本例中为“GitHub Actions Demo”。

  4. From the list of workflow runs, click the name of the run you want to see, in this example “USERNAME is testing out GitHub Actions.”
    从工作流运行列表中,单击要查看的运行的名称,在此示例中为“USERNAME istesting out GitHub Actions”。
  5. In the left sidebar of the workflow run page, under Jobs, click the Explore-GitHub-Actions job.
    在工作流运行页面左侧边栏中的“作业”下,单击“Explore-GitHub-Actions”作业。

  6. The log shows you how each of the steps was processed. Expand any of the steps to view its details.
    日志显示每个步骤的处理方式。展开任意步骤以查看其详细信息。

    For example, you can see the list of files in your repository:
    例如,您可以查看存储库中的文件列表:

The example workflow you just added is triggered each time code is pushed to the branch, and shows you how GitHub Actions can work with the contents of your repository. For an in-depth tutorial, see “Understanding GitHub Actions.”

每次将代码推送到分支时都会触发您刚刚添加的示例工作流程,并向您展示 GitHub Actions 如何处理存储库的内容。有关深入的教程,请参阅“了解 GitHub 操作”。

More starter workflows

GitHub provides preconfigured starter workflows that you can customize to create your own continuous integration workflow. GitHub analyzes your code and shows you CI starter workflows that might be useful for your repository. For example, if your repository contains Node.js code, you’ll see suggestions for Node.js projects. You can use starter workflows as a starting place to build your custom workflow or use them as-is.

GitHub 提供了预配置的入门工作流程,您可以自定义这些工作流程以创建您自己的持续集成工作流程。 GitHub 会分析您的代码并向您展示可能对您的存储库有用的 CI 入门工作流程。例如,如果您的存储库包含 Node.js 代码,您将看到有关 Node.js 项目的建议。您可以使用入门工作流程作为构建自定义工作流程的起点,也可以按原样使用它们。

You can browse the full list of starter workflows in the actions/starter-workflows repository.

您可以在 actions/starter-workflows 存储库中浏览入门工作流程的完整列表。

Next steps

GitHub Actions can help you automate nearly every aspect of your application development processes. Ready to get started? Here are some helpful resources for taking your next steps with GitHub Actions:

GitHub Actions 可以帮助您自动化应用程序开发流程的几乎每个方面。准备好开始了吗?以下是一些有用的资源,可帮助您使用 GitHub Actions 采取后续步骤:

  • For a quick way to create a GitHub Actions workflow, see “Using starter workflows.”
    有关创建 GitHub Actions 工作流程的快速方法,请参阅“使用入门工作流程”。
  • For continuous integration (CI) workflows to build and test your code, see “Automating builds and tests.”
    有关构建和测试代码的持续集成 (CI) 工作流程,请参阅“自动化构建和测试”。
  • For building and publishing packages, see “Publishing packages.”
    有关构建和发布包的信息,请参阅“发布包”。
  • For deploying projects, see “Deployment.”
    有关部署项目的信息,请参阅“部署”。
  • For automating tasks and processes on GitHub, see “Managing issues and pull requests.”
    有关 GitHub 上的自动化任务和流程的信息,请参阅“管理问题和拉取请求”。
  • For examples that demonstrate more complex features of GitHub Actions, including many of the above use cases, see “Examples.” You can see detailed examples that explain how to test your code on a runner, access the GitHub CLI, and use advanced features such as concurrency and test matrices.
    有关演示 GitHub Actions 更复杂功能的示例(包括上述许多用例),请参阅“示例”。您可以查看详细的示例,这些示例解释了如何在运行器上测试代码、访问 GitHub CLI 以及使用并发和测试矩阵等高级功能。
  • If you want to certify your proficiency in automating workflows and accelerating development with GitHub Actions, you can earn a GitHub Actions certificate with GitHub Certifications. For more information, see “About GitHub Certifications.”
    如果您想证明您在自动化工作流程和使用 GitHub Actions 加速开发方面的熟练程度,您可以通过 GitHub Certifications 获得 GitHub Actions 证书。有关更多信息,请参阅“关于 GitHub 认证”。
相关文章
|
2月前
|
对象存储
一个通过 GitHub Action 将 GitHub 仓库与阿里云 OSS 完全同步的脚本
一种将 GitHub 仓库完全同步到阿里云 OSS 的方法。
|
4月前
|
Linux C++ Docker
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
|
4月前
|
数据安全/隐私保护
【Azure Developer】Github Action使用Azure/login@v1插件登录遇见错误的替代方案
【Azure Developer】Github Action使用Azure/login@v1插件登录遇见错误的替代方案
|
4月前
|
存储
【Azure Developer】Github Action部署资源(ARM模板)到Azure中国区时,遇见登录问题的解决办法
【Azure Developer】Github Action部署资源(ARM模板)到Azure中国区时,遇见登录问题的解决办法
|
6月前
|
数据安全/隐私保护 开发者 Docker
国内docker公开镜像站的关闭!别急,docker_image_pusher 使用Github Action将国外的Docker镜像转存到阿里云私有仓库
通过使用 docker_image_pusher 这样的开源项目,我们能够轻松地解决国内访问 Docker 镜像拉取速度慢及拉去失败的问题,同时保证了镜像的稳定性和安全性。利用 Github Action 的自动化功能,使得这一过程更加简单和高效。
1903 2
【完美解决】Github action报错remote: Write access to repository not granted.
【完美解决】Github action报错remote: Write access to repository not granted.
|
6月前
|
jenkins 物联网 测试技术
干货分享!基于 Github Action 的 taosX CI 搭建
去年随着 3.1.1.0 版本的发布,TDengine 数据接入工具 taosX 正式推出。该工具具备强大的数据抓取、清洗、转换及加载(ETL)功能。它不仅能无缝对接物联网中的 MQTT 协议,更重要的是能够连接到工业数据源如 OPC-UA、OPC-DA、PI System 等。借助这一模块,工业场景中常用的 SCADA、DCS 等系统无需编写任何代码,仅需通过简单配置即可实现数据的实时、持续导入至 TDengine。
70 1
|
7月前
|
供应链 安全 jenkins
|
缓存 前端开发 持续交付
白嫖github的Action做定时任务
白嫖github的Action做定时任务
白嫖github的Action做定时任务
|
持续交付 开发工具 git
【白嫖】GitHub Action 云扫描器
GitHub Action介绍 GitHub Actions 是一种持续集成和持续交付 (CI/CD) 平台,可用于自动化构建、测试和部署应用程序,执行代码质量检查,创建和发布软件包,发送通知,执行持续集成和持续部署等等。 可以根据自己的需求和工作流程来定义和配置这些自动化任务 。 - 官方中文文档 (https //docs.github.com/zh/actions/quick
158 0