Note: GitHub Actions was available for GitHub Enterprise Server 2.22 as a limited beta. The beta has ended. GitHub Actions is now generally available in GitHub Enterprise Server 3.0 or later. For more information, see the GitHub Enterprise Server 3.0 release notes.
- For more information about upgrading to GitHub Enterprise Server 3.0 or later, see "Upgrading GitHub Enterprise Server."
- For more information about configuring GitHub Actions after you upgrade, see the documentation for GitHub Enterprise Server 3.0.
Note: GitHub-hosted runners are not currently supported on GitHub Enterprise Server. You can see more information about planned future support on the GitHub public roadmap.
Introduction
This tutorial demonstrates how to use the peter-evans/create-or-update-comment
action to comment on an issue when a specific label is applied. For example, when the help-wanted
label is added to an issue, you can add a comment to encourage contributors to work on the issue.
In the tutorial, you will first make a workflow file that uses the peter-evans/create-or-update-comment
action. Then, you will customize the workflow to suit your needs.
Creating the workflow
-
Choose a repository where you want to apply this project management workflow. You can use an existing repository that you have write access to, or you can create a new repository. For more information about creating a repository, see "Creating a new repository."
-
In your repository, create a file called
.github/workflows/YOUR_WORKFLOW.yml
, replacingYOUR_WORKFLOW
with a name of your choice. This is a workflow file. For more information about creating new files on GitHub, see "Creating new files." -
Copy the following YAML contents into your workflow file.
YAML # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support # documentation. name: Add comment on: issues: types: - labeled jobs: add-comment: if: github.event.label.name == 'help-wanted' runs-on: ubuntu-latest steps: - name: Add comment uses: peter-evans/create-or-update-comment@a35cf36e5301d70b76f316e867e7788a55a31dae with: issue-number: ${{ github.event.issue.number }} body: | This issue is available for anyone to work on. **Make sure to reference this issue in your pull request.** :sparkles: Thank you for your contribution! :sparkles:
-
Customize the parameters in your workflow file:
- Replace
help-wanted
inif: github.event.label.name == 'help-wanted'
with the label that you want to act on. If you want to act on more than one label, separate the conditions with||
. For example,if: github.event.label.name == 'bug' || github.event.label.name == 'fix me'
will comment whenever thebug
orfix me
labels are added to an issue. - Change the value for
body
to the comment that you want to add. GitHub flavored markdown is supported. For more information about markdown, see "Basic writing and formatting syntax."
- Replace
-
Commit your workflow file to the default branch of your repository. For more information, see "Creating new files."
Testing the workflow
Every time an issue in your repository is labeled, this workflow will run. If the label that was added is one of the labels that you specified in your workflow file, the peter-evans/create-or-update-comment
action will add the comment that you specified to the issue.
Test your workflow by applying your specified label to an issue.
- Open an issue in your repository. For more information, see "Creating an issue."
- Label the issue with the specified label in your workflow file. For more information, see "Managing labels."
- To see the workflow run triggered by labeling 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 labeled should have a comment added.
Next steps
- To learn more about additional things you can do with the
peter-evans/create-or-update-comment
action, like adding reactions, visit thepeter-evans/create-or-update-comment
action documentation.