-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
175 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
174 changes: 174 additions & 0 deletions
174
new-repository-request-example/workflows/issue-comment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.