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 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
Your IssueOps workflow is officially complete! For the complete workflow files,
check out the
new-repository-request-example
directory.