Approve

In the Approved state, we know that the issue has been approved and we can begin processing it. 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 Approved state when an authorized user comments on the request with .approve. However, immediately after reaching this state, we know we can create the repository and 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 approved and what is going to happen next. Or, comment on the issue with a summary of the changes that have taken place.
  • 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 approved.
  • When closing an issue, choosing an appropriate reason is useful for future reporting. For denied requests, closing an issue as not_planned may be misleading. Consider completed instead.

New repository request

When a new repository request is approved, we need to do the following:
  1. Create the repository
  2. Comment on the issue
  3. Close the issue
1# This job is responsible for handling approved requests.
2approve:
3  name: Approve Request
4  runs-on: ubuntu-latest
5
6  # Only run after validation has completed.
7  needs: validate
8
9  steps:
10    - name: Approve Command
11      id: approve
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: .approve
18
19    # Create the repository.
20    - if: ${{ steps.approve.outputs.continue == 'true' }}
21      name: Create Repository
22      id: create
23      uses: actions/github-script@vX.X.X
24      with:
25        github-token: ${{ secrets.MY_TOKEN }}
26        script: |
27          const request = JSON.parse('${{ needs.validate.outputs.request }}')
28          await github.rest.repos.createInOrg({
29            org: '${{ github.repository_owner }}',
30            name: request.name,
31          })
32
33    # Comment on the issue to let the user know their request was denied.
34    - if: ${{ steps.approve.outputs.continue == 'true' }}
35      name: Post Comment
36      id: comment
37      uses: peter-evans/create-or-update-comment@vX.X.X
38      with:
39        issue-number: ${{ github.event.issue.number }}
40        body:
41          ':tada: This request has been approved! Your repository has been
42          created.'
43
44    # Close the issue.
45    - if: ${{ steps.approve.outputs.continue == 'true' }}
46      name: Close Issue
47      id: close
48      run: gh issue close ${{ github.event.issue.number }} --reason completed

Next steps

Your IssueOps workflow is officially complete!