Skip to content

Commit

Permalink
Add an example workflow file.
Browse files Browse the repository at this point in the history
  • Loading branch information
desrosj committed Jan 22, 2024
1 parent eb749ba commit 8374a02
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 36 deletions.
38 changes: 2 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,6 @@ This GitHub Action Helps with collecting contributors associated with a pull req

## Example Workflow File

To get started, you will want to copy the contents of the given example into `.github/workflows/wordpress-props.yml` and push that to your repository. You are welcome to name the file something else.
To get started, copy and commit the `example-props-bot.yml` file into the `.github/workflows` directory in your project's repository.

```yml
name: Props Bot

on:
# Gathers all participants for pull requests to assist in giving proper credit.
pull_request:
issue_comment:
pull_request_review:
types:
- submitted
pull_request_review_comment:
types:
- created

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
pull_request_participants:
name: Collect props
runs-on: ubuntu-latest
timeout-minutes: 20

# Collects a list of contributors for a pull request and shares a list of
# Co-authored-by: trailers for merging contributors to copy into the commit message.
steps:
- name: Compile contributor list and comment on the PR
uses: WordPress/props-bot@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
```
The example file is generously documented to
76 changes: 76 additions & 0 deletions example-props-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Props Bot

on:
# This event runs anytime a PR is (re)opened, updated, or labeled.
# The logic below will look for
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
# This event runs anytime a comment is added or deleted.
# You cannot filter this event to happen for PR comments only.
# However, the logic below does short-circuit the workflow for issues.
issue_comment:
type:
- created
- deleted
# This event will run everytime a new PR review is created.
pull_request_review:
types:
- submitted
# This event runs anytime a PR review comment is added or deleted.
pull_request_review_comment:
types:
- created
- deleted

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ contains( fromJSON( '["pull_request", "pull_request_review", "pull_request_review_comment"]' ), github.event_name ) && github.head_ref || github.sha }}
cancel-in-progress: true

# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}

jobs:
# Compiles a list of props for a pull request.
#
# Performs the following steps:
# - Collects a list of contributor props and leaves a comment.
# - Removes the props-bot label, if necessary.
props-bot:
name: Generate a list of props
runs-on: ubuntu-latest
permissions:
# The action needs permission `write` permission for PRs in order to add a comment.
pull-requests: write
contents: read
timeout-minutes: 20
if: |
contains( fromJSON( '["pull_request_review", "pull_request_review_comment"]' ), github.event_name ) ||
( github.event_name == 'issue_comment' && github.event.issue.pull_request ) ||
github.event.action != 'labeled' ||
'props-bot' == github.event.label.name
steps:
- name: Gather a list of contributors
uses: WordPress/props-bot-action@update/comment-format

- name: Remove the props-bot label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ github.event.action == 'labeled' && 'props-bot' == github.event.label.name }}
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: '${{ github.event.number }}',
name: 'props-bot'
});

0 comments on commit 8374a02

Please sign in to comment.