Skip to content

Commit

Permalink
Update example path
Browse files Browse the repository at this point in the history
  • Loading branch information
ncalteen committed Oct 31, 2023
1 parent bb3ce48 commit a59a43d
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/content/states-transitions/validate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ module.exports = async (field) => {
## New repository request

Recall from the
[issue form template](https://github.com/issue-ops/docs/blob/main/examples/ISSUE_TEMPLATE/new-repository-request.yml)
[issue form template](https://github.com/issue-ops/docs/blob/main/new-repository-request-example/ISSUE_TEMPLATE/new-repository-request.yml)
that the new repository request expects the following inputs:

| Input | Required | Options |
Expand Down
13 changes: 0 additions & 13 deletions examples/validator/failure.mustache

This file was deleted.

17 changes: 0 additions & 17 deletions examples/validator/success.mustache

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
174 changes: 174 additions & 0 deletions new-repository-request-example/workflows/issue-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
name: Issue Comment

# This workflow runs any time a comment is added to an issue. The comment body
# is read and used to determine what action to take.
on:
issue_comment:
types:
- created

jobs:
validate:
name: Validate Request
runs-on: ubuntu-latest

# Only run when the following conditions are true:
# - The issue has the `issueops:new-repository` label
# - The issue has the `issueops:validated` label
# - The issue does not have the `issueops:approved` label
# - The issue is open
if: |
contains(github.event.issue.labels.*.name, 'issueops:new-repository') &&
contains(github.event.issue.labels.*.name, 'issueops:validated') &&
contains(github.event.issue.labels.*.name, 'issueops:approved') == false &&
github.event.issue.state == 'open'
permissions:
contents: read
id-token: write
issues: write

outputs:
request: ${{ steps.parse.outputs.request }}

steps:
- name: Remove Labels
id: remove-label
uses: issue-ops/[email protected]
with:
action: remove
issue_number: ${{ github.event.issue.number }}
labels: |
issueops:validated
issueops:submitted
- name: Get App Token
id: token
uses: actions/[email protected]
with:
app_id: ${{ secrets.MY_GITHUB_APP_ID }}
private_key: ${{ secrets.MY_GITHUB_APP_PEM }}
owner: ${{ github.repository_owner }}

- name: Checkout
id: checkout
uses: actions/[email protected]

- name: Setup Node.js
id: setup-node
uses: actions/[email protected]
with:
node-version: 20
cache: npm

- name: Install Packages
id: npm
run: npm ci

- name: Parse Issue
id: parse
uses: issue-ops/[email protected]
with:
body: ${{ github.event.issue.body }}
issue-form-template: new-repository-request.yml

- name: Validate Issue
id: validate
uses: issue-ops/[email protected]
with:
issue-form-template: new-repository-request.yml
github-token: ${{ steps.token.outputs.token }}
parsed-issue-body: ${{ steps.parse.outputs.json }}

- if: ${{ steps.validate.outputs.result == 'success' }}
name: Add Validated Label
id: add-label
uses: issue-ops/[email protected]
with:
action: add
issue_number: ${{ github.event.issue.number }}
labels: |
issueops:validated
approve:
name: Approve Request
runs-on: ubuntu-latest

# Only run after validation has completed.
needs: validate

steps:
- name: Approve Command
id: approve
uses: github/[email protected]
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/[email protected]
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/[email protected]
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

deny:
name: Deny Request
runs-on: ubuntu-latest

# Only run after validation has completed.
needs: validate

steps:
- name: Deny Command
id: deny
uses: github/[email protected]
with:
allowed_contexts: issue
allowlist: octo-org/approvers
allowlist_pat: ${{ secrets.MY_TOKEN }}
command: .deny

# Comment on the issue to let the user know their request was denied.
- if: ${{ steps.deny.outputs.continue == 'true' }}
name: Post Comment
id: comment
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body:
':no_entry_sign: This request has been denied! This issue will be
closed shortly.'

# Close the issue.
- if: ${{ steps.deny.outputs.continue == 'true' }}
name: Close Issue
id: close
run:
gh issue close ${{ github.event.issue.number }} --reason not_planned
File renamed without changes.

0 comments on commit a59a43d

Please sign in to comment.