Skip to content

Commit

Permalink
Add initial issue open workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ncalteen committed Jan 10, 2025
1 parent 2ad8e2d commit 894abf7
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/process-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Process Issue Open/Edit

on:
issues:
types:
- opened
- edited

permissions:
contents: read
id-token: write
issues: write

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

if: |
contains(github.event.issue.labels.*.name, 'reservation')
steps:
- name: Get GitHub App Token
id: token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.ISSUEOPS_APP_ID }}
private-key: ${{ secrets.ISSUEOPS_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}

# Remove the validated label. This will be re-added if validation passes.
- name: Remove Validated Label
id: remove-label
uses: issue-ops/labeler@v2
with:
action: remove
github_token: ${{ steps.token.outputs.token }}
labels: |
validated
issue_number: ${{ github.event.issue.number }}
repository: ${{ github.repository }}

# Parse the issue body into machine-readable JSON, so that it can be
# processed by the rest of the workflow.
- name: Parse Issue body
id: parse
uses: issue-ops/parser@v4
with:
body: ${{ github.event.issue.body }}
issue-form-template: reservation.yml
workspace: ${{ github.workspace }}

# Validate early, and validate often! Validation should be run any time an
# issue is interacted with, to ensure that any changes to the issue body
# are valid.
- name: Validate Reservation Request
id: validate
uses: issue-ops/validator@v3
with:
add-comment: false
github-token: ${{ steps.token.outputs.token }}
issue-form-template: reservation.yml
issue-number: ${{ github.event.issue.number }}
parsed-issue-body: ${{ steps.parse.outputs.json }}
workspace: ${{ github.workspace }}

# If validation passed, add the validated label to the issue.
- if: ${{ steps.validate.outputs.result == 'success' }}
name: Add Validated Label
id: add-label
uses: issue-ops/labeler@v2
with:
action: add
github_token: ${{ steps.token.outputs.token }}
labels: |
validated
issue_number: ${{ github.event.issue.number }}
repository: ${{ github.repository }}

# If validation failed, add a comment to the issue explaining the failure.
- if: ${{ steps.validate.outputs.result == 'failure' }}
name: Add Validation Failure Comment
id: add-failure-comment
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `:sob: Something went wrong validating your request. Please edit the issue body or close this issue and submit a new one.
The following validation errors occurred:
${{ steps.validate.outputs.errors }}`
})

0 comments on commit 894abf7

Please sign in to comment.