Approve
- Alpha
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:
not_planned
may be
misleading. Consider completed
instead.When a new repository request is approved, we need to do the following:
# This job is responsible for handling approved requests.deny:name: Approve Requestruns-on: ubuntu-latest# Only run after validation has completed.needs: validatesteps:- name: Approve Commandid: approveuses: github/command@vX.X.Xwith:allowed_contexts: issueallowlist: octo-org/approversallowlist_pat: ${{ secrets.MY_TOKEN }}command: .approve# Create the repository.- if: ${{ steps.approve.outputs.continue == 'true' }}name: Create Repositoryid: createuses: actions/github-script@vX.X.Xwith: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 Commentid: commentuses: peter-evans/create-or-update-comment@vX.X.Xwith:issue-number: ${{ github.event.issue.number }}body:':tada: This request has been approved! Your repository has beencreated.'# Close the issue.- if: ${{ steps.approve.outputs.continue == 'true' }}name: Close Issueid: closerun: gh issue close ${{ github.event.issue.number }} --reason completed
Your IssueOps workflow is officially complete! For the complete workflow files,
check out the
new-repository-request-example
directory.