Approve

The request is approved and we can process it further.
  • Alpha

Overview

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 approved 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
# This job is responsible for handling approved requests.
deny:
name: Approve Request
runs-on: ubuntu-latest
# Only run after validation has completed.
needs: validate
steps:
- name: Approve Command
id: approve
uses: github/command@vX.X.X
with:
allowed_contexts: issue
allowlist: octo-org/approvers
allowlist_pat: ${{ secrets.MY_TOKEN }}
command: .approve
# Create the repository.
- if: ${{ steps.approve.outputs.continue == 'true' }}
name: Create Repository
id: create
uses: actions/github-script@vX.X.X
with:
github-token: ${{ secrets.MY_TOKEN }}
script: |
const request = JSON.parse('${{ needs.validate.outputs.request }}')
await github.rest.repos.createInOrg({
org: '${{ github.repository_owner }}',
name: request.name,
})
# Comment on the issue to let the user know their request was denied.
- if: ${{ steps.approve.outputs.continue == 'true' }}
name: Post Comment
id: comment
uses: peter-evans/create-or-update-comment@vX.X.X
with:
issue-number: ${{ github.event.issue.number }}
body:
':tada: This request has been approved! Your repository has been
created.'
# Close the issue.
- if: ${{ steps.approve.outputs.continue == 'true' }}
name: Close Issue
id: close
run: gh issue close ${{ github.event.issue.number }} --reason completed

Next steps

Your IssueOps workflow is officially complete! For the complete workflow files, check out the new-repository-request-example directory.