-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcd85fd
commit 0e1c60b
Showing
2 changed files
with
84 additions
and
0 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
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,56 @@ | ||
name: 'Toggle label' | ||
description: 'Toggle a label on a pull request' | ||
|
||
inputs: | ||
token: | ||
description: 'GitHub token to use. If passed, takes precedence over the `app-id` and `app-private-key` inputs.' | ||
|
||
app-id: | ||
description: 'The app ID of the app.' | ||
|
||
private-key: | ||
description: 'The private key of the app.' | ||
|
||
label: | ||
description: 'The label to toggle' | ||
required: true | ||
|
||
toggle: | ||
description: 'Whether to add or remove the label.' | ||
default: 'auto' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: myparcelnl/actions/get-github-token@v3 | ||
id: token | ||
with: | ||
token: ${{ inputs.token }} | ||
app-id: ${{ inputs.app-id }} | ||
private-key: ${{ inputs.private-key }} | ||
|
||
- name: 'Add label' | ||
uses: actions/github-script@v6 | ||
if: (inputs.toggle == 'true' || inputs.toggle == 'auto') && !contains(github.event.pull_request.labels.*.name, '${{ inputs.label }}') | ||
with: | ||
github-token: ${{ steps.token.outputs.token }} | ||
script: | | ||
github.rest.issues.addLabels({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ['${{ inputs.label }}'] | ||
}); | ||
- name: 'Remove label' | ||
uses: actions/github-script@v6 | ||
if: (inputs.toggle == 'false' || inputs.toggle == 'auto') && contains(github.event.pull_request.labels.*.name, '${{ inputs.label }}') | ||
with: | ||
github-token: ${{ steps.token.outputs.token }} | ||
script: | | ||
github.rest.issues.removeLabel({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ['${{ inputs.label }}'] | ||
}); |