Skip to content

Commit

Permalink
[chore] Add add-labels workflow (open-telemetry#12478)
Browse files Browse the repository at this point in the history
This PR adds a workflow that will add the "good first issue" and "help wanted" labels when someone comments on an issue with exactly "/good-first-issue" and "/help-wanted"
  • Loading branch information
TylerHelmuth committed Jul 26, 2022
1 parent 8ecdb13 commit d963e97
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/add-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Add Labels'
on:
issue_comment:
types: [created]

jobs:
add-labels:
if: ${{ !github.event.issue.pull_request && (github.event.comment.body == '/help-wanted' || github.event.comment.body == '/good-first-issue' ) }}

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Run update permissions
run: chmod +x ./.github/workflows/scripts/add-labels.sh

- name: Run add-labels.sh
run: ./.github/workflows/scripts/add-labels.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE: ${{ github.event.issue.number }}
COMMENT: ${{ github.event.comment.body }}
30 changes: 30 additions & 0 deletions .github/workflows/scripts/add-labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# Copyright The OpenTelemetry Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#

if [ -z "${ISSUE}" ] || [ -z "${COMMENT}" ]; then
exit 0
fi

declare -A labels
labels["/good-first-issue"]="good first issue"
labels["/help-wanted"]="help wanted"


if [ -n "${labels["${COMMENT}"]}" ] ; then
gh issue edit "${ISSUE}" --add-label "${labels["${COMMENT}"]}"
fi
3 changes: 1 addition & 2 deletions .github/workflows/scripts/ping-codeowners.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ if [[ "${OWNERS}" =~ "${SENDER}" ]]; then
exit 0
fi

gh issue comment ${ISSUE} --body "Pinging code owners: ${OWNERS}"

gh issue comment ${ISSUE} --body "Pinging code owners: ${OWNERS}. See [Adding Labels via Comments](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#adding-labels-via-comments) if you do not have permissions to add labels yourself."
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ in general try to follow them.
- `replace` statements in `go.mod` files can be automatically inserted by running `make crosslink`. For more information
on the `crosslink` tool see the README [here](https://github.com/open-telemetry/opentelemetry-go-build-tools/tree/main/crosslink).

## Adding Labels via Comments

In order to facilitate proper label usage and to empower Code Owners, you are able to add the following labels to issues via comments.

| Label | Generating Comment |
|--------------------|--------------------|
| `good first issue` | /good-first-issue |
| `help wanted` | /help-wanted |

Currently, labels can only be created via comment, not deleted. You must make a new comment; you cannot edit an existing comment.

## Becoming a Code Owner

A Code Owner is responsible for a component within Collector Contrib, as indicated by the [CODEOWNERS file](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/.github/CODEOWNERS). That responsibility includes maintaining the component, responding to issues, and reviewing pull requests.
Expand Down

0 comments on commit d963e97

Please sign in to comment.