Nota: Actualmente los ejecutores hospedados en GitHub no se admiten en GitHub Enterprise Server. Puede ver más información sobre la compatibilidad futura planeada en GitHub public roadmap.
Introduction
This tutorial demonstrates how to use the actions/github-script action in a workflow to label newly opened or reopened issues. For example, you can add the triage label every time an issue is opened or reopened. Then, you can see all issues that need to be triaged by filtering for issues with the triage label.
The actions/github-script action allows you to easily use the GitHub API in a workflow.
In the tutorial, you will first make a workflow file that uses the actions/github-script action. Then, you will customize the workflow to suit your needs.
Creating the workflow
-
Elige un repoisitorio en donde quieras aplicar este fluljo de trabajo de administración de proyectos. Puedes utilizar un repositorio existente al cual tengas acceso de escritura o puedes crear un repositorio nuevo. Para más información sobre cómo crear un repositorio, vea "Creación de un repositorio".
-
En el repositorio, cree un archivo denominado
.github/workflows/YOUR_WORKFLOW.yml, y reemplaceYOUR_WORKFLOWpor el nombre que prefiera. Este es un archivo de flujo de trabajo. Para más información sobre cómo crear archivos en GitHub, vea "Creación de archivos". -
Copy the following YAML contents into your workflow file.
YAML name: Label issues on: issues: types: - reopened - opened jobs: label_issues: runs-on: ubuntu-latest permissions: issues: write steps: - uses: actions/github-script@v5 with: script: | github.rest.issues.addLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, labels: ["triage"] }) -
Customize the
scriptparameter in your workflow file:- The
issue_number,owner, andrepovalues are automatically set using thecontextobject. You do not need to change these. - Change the value for
labelsto the list of labels that you want to add to the issue. Separate multiple labels with commas. For example,["help wanted", "good first issue"]. For more information about labels, see "Managing labels."
- The
-
Confirma tu archivo de flujo de trabajo en la rama predeterminada de tu repositorio. Para obtener más información, consulte "Creación de archivos".
Testing the workflow
Every time an issue in your repository is opened or reopened, this workflow will add the labels that you specified to the issue.
Test out your workflow by creating an issue in your repository.
- Create an issue in your repository. For more information, see "Creating an issue."
- To see the workflow run that was triggered by creating the issue, view the history of your workflow runs. For more information, see "Viewing workflow run history."
- When the workflow completes, the issue that you created should have the specified labels added.
Next steps
- To learn more about additional things you can do with the
actions/github-scriptaction, see theactions/github-scriptaction documentation. - To learn more about different events that can trigger your workflow, see "Events that trigger workflows."
- Search GitHub for examples of workflows using this action.

