-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Trajan0x <[email protected]>
- Loading branch information
Showing
7 changed files
with
153 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Add Label | ||
|
||
This action adds a specified label to an issue or pull request. | ||
|
||
## Inputs | ||
* `issue_number`: The issue number derived from the event payload. Default is `${{ github.event.number }}` then `${{ github.event.issue.number }}`. Action will fail if neither of these is present. If you need to use this action on a push event (or any event not associated directly with an `issue` or `pull_request`, please see [gh-find-current-pr](https://github.com/jwalton/gh-find-current-pr)) | ||
* `label`: The label to add to the issue | ||
|
||
|
||
## Usage: | ||
|
||
```yaml | ||
- name: Add Label | ||
uses: ./.github/actions/add-label | ||
with: | ||
label: 'needs-go-generate-${{matrix.package}}' | ||
issue-number: ${{github.event.number}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Add Label | ||
description: Add a label to the issue or pull request | ||
inputs: | ||
issue_number: | ||
description: 'The issue number to associate with. Defaults to the current issue or pull request number used to trigger the action.' | ||
required: false | ||
default: '' | ||
label: | ||
description: 'The label to add.' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
# # TODO, dedupe w/ remove-label | ||
- name: Resolve issue number | ||
id: resolve_issue_number | ||
run: | | ||
if [[ -n '${{ inputs.issue_number }}' ]]; then | ||
echo 'Using input issue number: ${{ inputs.issue_number }}' | ||
echo '::set-output name=issue::${{ inputs.issue_number }}' | ||
elif [[ -n '${{ github.event.number }}' ]]; then | ||
echo 'Using event number: ${{ github.event.number }}' | ||
echo '::set-output name=issue::${{ github.event.number }}' | ||
elif [[ -n '${{ github.event.issue.number }}' ]]; then | ||
echo 'Using event issue number: ${{ github.event.issue.number }}' | ||
echo '::set-output name=issue::${{ github.event.issue.number }}' | ||
else | ||
echo 'Could not determine issue number' | ||
exit 1 | ||
fi | ||
shell: bash | ||
|
||
- name: Add Label | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.issues.addLabels({ | ||
issue_number: ${{ steps.resolve_issue_number.outputs.issue }}, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ['${{ inputs.label }}'] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Remove Label | ||
|
||
This action removes a specified label to an issue or pull request. | ||
|
||
## Inputs | ||
* `issue_number`: The issue number derived from the event payload. Default is `${{ github.event.number }}` then `${{ github.event.issue.number }}`. Action will fail if neither of these is present. If you need to use this action on a push event (or any event not associated directly with an `issue` or `pull_request`, please see [gh-find-current-pr](https://github.com/jwalton/gh-find-current-pr)) | ||
* `label`: The label to add to the issue | ||
|
||
|
||
```yaml | ||
- name: Remove Label | ||
uses: ./.github/actions/remove-label | ||
with: | ||
label: 'needs-go-generate-${{matrix.package}}' | ||
issue-number: ${{github.event.number}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Remove Label | ||
description: Remove a label to the issue or pull request | ||
inputs: | ||
issue_number: | ||
description: 'The issue number to associate with. Defaults to the current issue or pull request number used to trigger the action.' | ||
required: false | ||
default: '' | ||
label: | ||
description: 'The label to add.' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
# TODO, dedupe w/ add-label | ||
- name: Resolve issue number | ||
id: resolve_issue_number | ||
run: | | ||
if [[ -n '${{ inputs.issue_number }}' ]]; then | ||
echo 'Using input issue number: ${{ inputs.issue_number }}' | ||
echo '::set-output name=issue::${{ inputs.issue_number }}' | ||
elif [[ -n '${{ github.event.number }}' ]]; then | ||
echo 'Using event number: ${{ github.event.number }}' | ||
echo '::set-output name=issue::${{ github.event.number }}' | ||
elif [[ -n '${{ github.event.issue.number }}' ]]; then | ||
echo 'Using event issue number: ${{ github.event.issue.number }}' | ||
echo '::set-output name=issue::${{ github.event.issue.number }}' | ||
else | ||
echo 'Could not determine issue number' | ||
exit 1 | ||
fi | ||
shell: bash | ||
|
||
- name: Remove Label | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.issues.removeLabel({ | ||
issue_number: ${{ steps.resolve_issue_number.outputs.issue }}, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: ['${{ inputs.label }}'] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters