-
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
Showing
1 changed file
with
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Close issue on /close | ||
|
||
on: | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
jobs: | ||
closeIssueOnClose: | ||
# Skip this job if the comment was created/edited on a PR | ||
if: ${{ !github.event.issue.pull_request }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
pull-requests: none | ||
contents: read | ||
|
||
steps: | ||
- run: echo "command=false" >> $GITHUB_ENV | ||
|
||
- name: Check for /close command | ||
id: check_close_command | ||
run: | | ||
if [[ "${{ contains(github.event.comment.body, '/close') }}" == "true" ]]; then | ||
echo "command=true" >> $GITHUB_ENV | ||
echo "close_command=true" >> $GITHUB_ENV | ||
echo "reopen_command=false" >> $GITHUB_ENV | ||
else | ||
echo "close_command=false" >> $GITHUB_ENV | ||
fi | ||
- name: Check for /open or /reopen command | ||
id: check_reopen_command | ||
run: | | ||
if [[ "${{ contains(github.event.comment.body, '/open') }}" == "true" ]] || [[ "${{ contains(github.event.comment.body, '/reopen') }}" == "true" ]]; then | ||
echo "command=true" >> $GITHUB_ENV | ||
echo "reopen_command=true" >> $GITHUB_ENV | ||
echo "close_command=false" >> $GITHUB_ENV | ||
else | ||
echo "reopen_command=false" >> $GITHUB_ENV | ||
fi | ||
- name: Check if the user is allowed | ||
id: check_user | ||
if: env.command == 'true' | ||
run: | | ||
ALLOWED_USERS=("fam007e") | ||
if [[ " ${ALLOWED_USERS[@]} " =~ " ${{ github.event.comment.user.login }} " ]]; then | ||
echo "user=true" >> $GITHUB_ENV | ||
else | ||
echo "user=false" >> $GITHUB_ENV | ||
fi | ||
- name: Close issue if conditions are met | ||
if: env.close_command == 'true' && env.user == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ISSUE_NUMBER: ${{ github.event.issue.number }} | ||
run: | | ||
echo Closing the issue... | ||
if [[ "${{ contains(github.event.comment.body, 'not planned') }}" == "true" ]]; then | ||
gh issue close $ISSUE_NUMBER --repo ${{ github.repository }} --reason 'not planned' | ||
else | ||
gh issue close $ISSUE_NUMBER --repo ${{ github.repository }} | ||
fi | ||
- name: Reopen issue if conditions are met | ||
if: env.reopen_command == 'true' && env.user == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ISSUE_NUMBER: ${{ github.event.issue.number }} | ||
run: | | ||
echo Reopening the issue... | ||
gh issue reopen $ISSUE_NUMBER --repo ${{ github.repository }} |