Deny
In theDenied
state, we know that the issue has been denied and there is no further action to take. This is one of the first states in the workflow where we can perform an unguarded transition.In our repository workflow, a request is transitioned to the Denied
state when an authorized user comments on the request with .deny
. However, immediately after reaching this state, we want to close the issue (moving it to the Closed
state). This is called an unguarded transition because there is no condition that must be met before the transition occurs.The actual implementation of this transition is up to you! There are a few recommendations to keep in mind:- Communication to users is always helpful! Consider leaving a comment on the issue to let the user know that their request has been denied and what steps, if any, they can take next.
- Even after an issue is closed, users can interact with it. If you want to prevent this, you can lock the issue.
- Labels are a great way to organize issues. Consider adding a label to the issue to indicate that it has been denied.
- When closing an issue, choosing an appropriate reason is useful for future reporting. For denied requests, closing an issue as
completed
may be misleading. Considernot_planned
instead.
New repository request
When a new repository request is denied, we want to close the issue and leave a comment for the user. We should also add an appropriate label so we know the request was closed as denied.1# This job is responsible for handling denied requests.
2deny:
3 name: Deny Request
4 runs-on: ubuntu-latest
5
6 # Only run after validation has completed.
7 needs: validate
8
9 steps:
10 - name: Deny Command
11 id: deny
12 uses: github/command@vX.X.X
13 with:
14 allowed_contexts: issue
15 allowlist: octo-org/approvers
16 allowlist_pat: ${{ secrets.MY_TOKEN }}
17 command: .deny
18
19 # Comment on the issue to let the user know their request was denied.
20 - if: ${{ steps.deny.outputs.continue == 'true' }}
21 name: Post Comment
22 id: comment
23 uses: peter-evans/create-or-update-comment@vX.X.X
24 with:
25 issue-number: ${{ github.event.issue.number }}
26 body:
27 ':no_entry_sign: This request has been denied! This issue will be
28 closed shortly.'
29
30 # Close the issue.
31 - if: ${{ steps.deny.outputs.continue == 'true' }}
32 name: Close Issue
33 id: close
34 run: gh issue close ${{ github.event.issue.number }} --reason not_planned