Resumen de ejemplo
This article uses an example workflow to demonstrate some of the main CI features of GitHub Actions. When this workflow is triggered, it tests your code using a matrix of test combinations with npm test
.
The following diagram shows a high level view of the workflow's steps and how they run within the job:
Características utilizadas en este ejemplo
The example workflow demonstrates the following capabilities of GitHub Actions:
Característica | Implementación |
---|---|
Manually running a workflow from the UI: | workflow_dispatch |
Triggering a workflow to run automatically: | pull_request |
Running a workflow at regular intervals: | schedule |
Setting permissions for the token: | permissions |
Controlling how many workflow runs or jobs can run at the same time: | concurrency |
Ejecutar el job en ejecutores diferentes, dependiendo del repositorio: | runs-on |
Preventing a job from running unless specific conditions are met: | if |
Using a matrix to create different test configurations: | matrix |
Cloning your repository to the runner: | actions/checkout |
Installing node on the runner: | actions/setup-node |
Caching dependencies: | actions/cache |
Ejemplo de flujo de trabajo
The following workflow was created by the GitHub Docs Engineering team. To review the latest version of this file in the github/docs
repository, see test.yml
.
Note: Each line of this workflow is explained in the next section at "Understanding the example."
|
Cómo entender el ejemplo
The following table explains how each of these features are used when creating a GitHub Actions workflow.
Código | Explicación |
---|---|
|
The name of the workflow as it will appear in the "Actions" tab of the GitHub repository. |
|
La palabra clave |
|
Add the |
|
Agrega el evento |
|
Add the |
|
Modifica los permisos predeterminados que se otorgan al |
|
Crea un grupo de concurrencia para los eventos específicos y utiliza el operador |
|
Cancela cualquier job o flujo de trabajo concurrentes en el mismo grupo de concurrencia. |
|
Agrupa todos los jobs que se ejecutan en el archivo de flujo de trabajo. |
|
Defines a job with the ID |
|
Configura el job para ejecutarse en un ejecutor hospedado en GitHub o en un ejecutor auto-hospedado, dependiendo del repositorio que ejecuta el flujo de trabajo. En este ejemplo, el job se ejecutará en un ejecutor auto-hospedado si se nombra al repositorio |
|
Sets the maximum number of minutes to let the job run before it is automatically canceled. For more information, see |
|
This section defines the build matrix for your jobs. |
|
Setting |
|
Creates a matrix named |
|
Groups together all the steps that will run as part of the |
|
La palabra clave |
|
If the current repository is the |
|
If the current repository is the |
|
If the current repository is the |
|
This step runs a command to check out LFS objects from the repository. |
|
This step uses the |
|
This step runs a shell command that uses an output from the previous step to create a file containing the list of files changed in the pull request. |
|
Este paso utiliza la acción |
|
This step runs the |
|
This step uses the |
|
This step runs the build script. |
|
This step runs the tests using |
Pasos siguientes
- To learn about GitHub Actions concepts, see "Understanding GitHub Actions."
- For more step-by-step guide for creating a basic workflow, see "Quickstart for GitHub Actions."
- If you're comfortable with the basics of GitHub Actions, you can learn about workflows and their features at "About workflows."